Hi I currently have this version of ds in composer.lock: "version": "8.x-3.0-beta4+0-dev", "datestamp": "1493795284"
When I create a paragraph entity that has no fields yet, after I try to switch its layout to a new one using DS / Manage Display, I get the following error.
The website encountered an unexpected error. Please try again later. TypeError: Argument 1 passed to _ds_sort_fields() must be of the type array, null given, called in /var/www/thp/web/modules/contrib/ds/includes/field_ui.inc on line 399 in _ds_sort_fields() (line 1404 of modules/contrib/ds/includes/field_ui.inc). _ds_sort_fields(NULL, 'weight') (Line: 399) ds_field_ui_layouts_save(Array, Object) call_user_func_array('ds_field_ui_layouts_save', Array) (Line: 111) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585) Drupal\Core\Form\FormBuilder->processForm('entity_view_display_edit_form', Array, Object) (Line: 314) Drupal\Core\Form\FormBuilder->buildForm('entity_view_display_edit_form', Object) (Line: 74) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) [.......]
This may be a bug on the Paragraphs side however. I put it here since it was DS related functions throwing the error. Please reassign to Paragraphs project if it is really a matter to be addressed on that side. However if generally speaking DS can't handle entities without fields something should probably be adjusted on this side.
Comment | File | Size | Author |
---|---|---|---|
#18 | 2877487-18-diff.txt | 1.43 KB | swentel |
#17 | 2877487-17.patch | 6.43 KB | swentel |
#13 | ds_fix_entities_without_fields.patch | 4.73 KB | NWOM |
Comments
Comment #2
aspilicious CreditAttribution: aspilicious commentedWhat version of core are you using?
Comment #3
HongPong CreditAttribution: HongPong as a volunteer and at kor group commentedcore version 8.3.2. Paragraphs is at "version": "8.x-1.1+16-dev", "datestamp": "1492678144" in the lockfile.
Comment #4
aspilicious CreditAttribution: aspilicious commentedCould you test this patch?
Comment #5
StryKaizerPatch in #4 solves error described. Thx!
This fix does show a new issue, where the custom coded DS fields are rendered below instead of in the expected regions areas, see screenshot.
Comment #6
workplaysleep CreditAttribution: workplaysleep commentedConfirm on the issue @StryKaizer mentions
Comment #7
DamienMcKennaThe patch gets past the initial error, but now I get two warnings:
_ds_sort_fields(Array, 'weight') (Line: 399)
_ds_sort_fields(Array, 'weight') (Line: 399)
This is in addition to the bug mentioned by @StryKaizer.
Incidentally, if I apply the patch, save the form (so the warnings above are shown) and then revert the patch the problems still happen.
Some other things to note:
Comment #8
Dozz CreditAttribution: Dozz commentedThe custom coded fields are rendered at the bottom because in EntityDisplayFormBase:form(), when there are no fields, the field ui table is not added so DS can't add anything to it.
In the patch attached, I add this table when it doesn't exist and attach the field_ui library.
Maybe it would have been a better solution to make EntityDisplayFormBase:form() add the table even when there are no fields, though.
Comment #9
Dozz CreditAttribution: Dozz commentedThe custom coded fields are rendered below because in EntityDisplayFormBase:form() the field ui table is not added when there are no fields so DS can't add anything to it.
In the patch attached, I add this table to the form when it doesn't exist and attach the field_ui library.
Maybe it would have been a better solution to make EntityDisplayFormBase:form() add the table even when there are no fields, though.
Comment #10
Dozz CreditAttribution: Dozz commentedMy comment didn't get posted with my patch for some reason, second attempt:
The custom coded fields are rendered at the bottom because in EntityDisplayFormBase:form() does not add the field ui table when there are no fields so DS can't add anything to this table.
In the patch attached, I add this table to the form when it doesn't exist and attach the field_ui library.
Maybe it would have been a better solution to make EntityDisplayFormBase:form() add the table even when there are no fields, though.
Comment #11
Dozz CreditAttribution: Dozz commentedMy comment didn't get posted with my patch for some reason, second attempt:
The custom coded fields are rendered at the bottom because in EntityDisplayFormBase:form() does not add the field ui table when there are no fields so DS can't add anything to this table.
In the patch attached, I add this table to the form when it doesn't exist and attach the field_ui library.
Maybe it would have been a better solution to make EntityDisplayFormBase:form() add the table even when there are no fields, though.
Comment #12
Dozz CreditAttribution: Dozz commentedMy comment didn't get posted with my patch for some reason, second attempt:
The custom coded fields are rendered at the bottom because in EntityDisplayFormBase:form() does not add the field ui table when there are no fields so DS can't add anything to this table.
In the patch attached, I add this table to the form when it doesn't exist and attach the field_ui library.
Maybe it would have been a better solution to make EntityDisplayFormBase:form() add the table even when there are no fields, though.
Comment #13
NWOM CreditAttribution: NWOM commented#12 fixed my issue! Thank you. Here is the patch again, and will hopefully be attached correctly.
Comment #14
damontgomery CreditAttribution: damontgomery at Palantir.net commentedWe've used #13 and I had a look over the code, so I'm marking this as tested.
The comments in the patch are helpful. I think it might also be useful to add comments about why we need to cast to an array in a few places, although I can make some guesses.
Please update if this needs more work / testing.
Thanks!
Comment #15
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedSo the patch fixes the fatal errors, that's at least a good step. The only remaning thing is that if you move a field from disabled to a region, the throbber keeps spinning (in my testing, I only have the 'Bundle name' field available in parapgraphs). It doesn't trigger a JS or request error, and hitting save is fine too. I'm going to check what's wrong here to see if I can get rid of that, maybe there's a missing library or so, because it might confuse users.
Comment #16
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedChecked with a different entity display, and when dropping a field, a request should be triggered to admin/structure/paragraphs_type/{paragraph_type}/display?ajax_form=1&_wrapper_format=drupal_ajax
This doesn't happen when there are no fields. As mentioned in my previous comment, it doesn't break anything, checking some more now.
Comment #17
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedOk, figured out the throbber. That's because the 'refresh' button isn't available (that's a hidden button at the bottom of the field ui table). Adding that as well triggers the request and the throbber goes away, and there are no errors. However, you're getting the many instances of the 'here are no fields yet added. You can add new fields on the Manage fields page.' warning.
Attached patch clears that warning and adds the refresh button.
Comment #18
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedThis is the (badly taken) diff.
Comment #19
stijndApplied #17. Issue fixed.
Comment #20
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedOk, cool, will commit soon
Comment #23
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedcommitted and pushed, thanks all!