Display Suite Forms does not seem to be compatible with nested entities.
Due to this, ds_forms can't be used with some modules like Scald in order to manage fields display.
The attached patch fixed this issue for me. All it does is add a parsing of $form child elements and search for additional form elements.
Could someone review this ?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | ds-2139269-10-nested-entities-fixes.patch | 3.12 KB | captainack |
| #4 | ds-2139269-4-by-si.mon-axel.rutz-Display-Suite-Form.patch | 3.58 KB | geek-merlin |
Comments
Comment #1
brice_gato commentedThis works for me.
Comment #2
geek-merlin@brice_gato: Thanks for crosslinkting this in the other issues.
Please next time close the others as a dup and link here, instead of re-uploading the patch several times.
Comment #3
geek-merlinThis needs work as the hook still runs too early - at least for profile2.
Comment #4
geek-merlinPatch flying in that adds altering hook order and fixes the issue for me (with profile2).
Raising prio as quite some important modules are blocked.
Please test and RTBC.
Comment #5
ifrikThe patch works for me with Scald.
Comment #6
gge commentedPatch #4 applied successfully but DS still doesn't work with Inline Entity Form.
Comment #7
geek-merlinSo this addreses at least profile2 and scald, let's RTBC this as of #5 and handle IEF in a followup.
Comment #8
captainack commentedThanks for the patch guys!
Just tested it and it fixes standalone profile2 forms, but it doesn't seem to fix them if they're attached to the registration form.
Comment #9
captainack commentedYup :( the first conditional passes ($bundle == 'user'), so the loop gets bypassed.
Furthermore, the $form_id in being passed to DS in the loop is probably gonna prevent profiles on the user_register_form from working, because $form_id will be user_register_form.
Comment #10
captainack commentedOkay so I was wrong about the second thing ($form_id is only used to check against a blacklist, which doesn't apply here). But regarding the first thing, I simply removed the else surrounding the second part, and everything seems to work. I tested:
- ds'ed profile2's own form
- ds'ed profile2 edit form attached to reg form
- ds'ed fields inside a field_collection
- non-ds'ed forms
Did you guys have a specific reason for the second block? It seems safe.
Anyway, I'll post a patch soon.
Comment #11
captainack commentedComment #12
philsward commentedGave the #11 patch a try and it doesn't seem to do much with Paragraphs :-/
Comment #13
philyPatch #11 works with Drupal 7.56, Display Suite 7.x-2.14 & Profile2 7.x-1.3.
Thanks
Comment #14
delacosta456 commentedPatch #11 applied but doesn't work for IEF+display suite.
Comment #15
geek-merlinSo #11 is #4 without the else() around the second code block.
This semms safe to me (author of #4) and if (as reported) this fixes additional (inline_registration) use cases, all the better.
So based on #5, #8, #13 this fixes the issue for profile2 and scald.
I'd propose to RTBC this and fix the other integrations in a followup.
Comment #16
capynet commentedIt does not work for paragraphs (at least nested)
Comment #17
sphism commentedThe code in #11 just seems to alter form items that are nested one level deeper. I think paragraphs_items will always be more than that since there's the field, language, items, etc.
But regardless you need to iterate deeper since paragraphs can contain other paragraphs.
I managed to get ds form working on nested paragraphs using this code, in case it's any use to anyone:
Originally I duplicated ds_forms_form_alter alterations into here but that seems dangerous, i don't think there's any issue calling the hook function directly like that. Anyone have any thoughts on that?
There's probably a better conditional to check if we want to iterate deeper, maybe looping through the field items parents and seeing if any of them are paragraphs, etc. Anyone know if there's a clever check for all fields that would need deeper iteration to cover paragraphs, inline entity form, scald, etc.