Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Afform - Fix saving and editing entity blocks #22963

Merged
merged 1 commit into from
Mar 19, 2022

Conversation

colemanw
Copy link
Member

Overview

Fixes dev/core#3120
Regression caused by #21218
Also fixes undefined variable errors when editing a block.

Before

Unable to save a block for an entity. Editor has console errors when editing blocks.

After

Fixed.

Technical Details

This was caused by #21218 renaming a block property, but the "Save block" popup did not get updated.

Fixes dev/core#3120
Regression caused by civicrm#21218
Also fixes undefined variable errors when editing a block.
@civibot
Copy link

civibot bot commented Mar 17, 2022

(Standard links)

@civibot civibot bot added the master label Mar 17, 2022
@colemanw colemanw changed the base branch from master to 5.48 March 17, 2022 18:22
@civibot civibot bot added 5.48 and removed master labels Mar 17, 2022
@colemanw
Copy link
Member Author

@andyburnsco since this is a regression PR for the RC branch it needs to be tested and and merged asap. Can you try it out today?

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Mar 18, 2022

I tried testing but with the patch applied I get error 500 when visiting the form builder admin page.

TypeError: Argument 1 passed to Civi\AfformAdmin\AfformAdminMeta::getApiEntity() must be of the type string, null given, called in ...\ext\afform\admin\Civi\Api4\Action\Afform\LoadAdminData.php on line 213 in Civi\AfformAdmin\AfformAdminMeta::getApiEntity() (line 60 of ...\ext\afform\admin\Civi\AfformAdmin\AfformAdminMeta.php).

@colemanw
Copy link
Member Author

@demeritcowboy since this patch only touches the JS side it wouldn't be able to cause that server-side error. But I remember seeing something similar recently and it was a caching issue.

@demeritcowboy
Copy link
Contributor

I had cleared caches and tried another install too.
The test site here isn't useful:

Untitled2

There error is happening during js loadAdminData, I assume here:

crmApi4('Afform', 'loadAdminData', {
. Is there something about this code change that affects what it sends to the server?

@colemanw
Copy link
Member Author

Is there something about this code change that affects what it sends to the server?

Not this patch, no. I assume you are getting that error with and without this patch.

@demeritcowboy
Copy link
Contributor

No it's fine without the patch. I'll try to get more details.

@eileenmcnaughton
Copy link
Contributor

I had a go at this with & without the patch - without the patch it seemed to save (unlike the issue report) but my console was full of red. With the patch the red went away & it still seemed to work

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Mar 18, 2022

It's not the saving, it's clicking the edit button on the form builder admin listing page, on the blocks tab.

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy yeah that worked for me with & without - but console errors without the patch - this is my block

image

@demeritcowboy
Copy link
Contributor

Ok weird because I was able to reproduce the initial report.

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy the edit button worked - I just saw console errors when I had the console tab open

@demeritcowboy
Copy link
Contributor

I had console errors AND it didn't work. Nothing happens when you click it. It's also on dmaster.demo now if you want to see it: https://dmaster.demo.civicrm.org/civicrm/admin/afform#/?tab=block
Click on the edit button for titleblock.

@colemanw
Copy link
Member Author

I think the error is because, for whatever reason, that block didn't save correctly (note missing entity-type):
image

@demeritcowboy
Copy link
Contributor

Right. And @eileenmcnaughton your block doesn't have a container.

@demeritcowboy
Copy link
Contributor

I think my confusion is that you have to delete your existing broken blocks, otherwise you still get errors after upgrading.

Then additionally there's a quirk or something where if you delete the block, then go edit the form, the block is gone, so you add it again, but then magically the original block comes back as a duplicate block on the form.

But yes starting from scratch, this fixes the edit problem.

As a minor note even after starting from scratch/clearing cache, I have a couple repeated warnings in drupal watchdog: Notice: Undefined index: #tag in Civi\Api4\Action\Afform\LoadAdminData->Civi\Api4\Action\Afform\{closure}() (line 113 of ...\ext\afform\admin\Civi\Api4\Action\Afform\LoadAdminData.php).

@colemanw
Copy link
Member Author

I think my confusion is that you have to delete your existing broken blocks

Yes, this PR prevents broken blocks from being created, but it doesn't fix existing broken blocks. I can try to do a followup for that once this is merged @demeritcowboy

@demeritcowboy
Copy link
Contributor

I forgot to put merge-ready but yes I think can merge.

@andyburnsco
Copy link
Contributor

andyburnsco commented Mar 23, 2022

I cleared cache, saved a new first/last name block, and can click edit now but then it looks like this:

image

Seeing all the JS errors still.

@colemanw
Copy link
Member Author

I'm not quite sure what to make of these reports that it's still broken because I'm not able to reproduce on a fresh copy of 5.48. After saving some name fields as a block, I can edit the block with no errors:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants