Currently the EntityDisplayFormBase works only with two regions: content and hidden.
The form basically puts all displayed fields into content region and the rest is put into the hidden region. This is not done based on the name of the region but only based on the fact that the field is displayed.
This makes adding new regions quite tricky since overriding the getRegions()
method just won't cut it.
If the form would preserve its current functionality, but it would just save the region name(currently only content, using hidden automatically for fields that are not displayed is fine with me) in the copyFormValuesToEntity()
method it would make it much easier to add custom regions and other modules, like DS for example, would not have to do so much additional processing.
Comment | File | Size | Author |
---|---|---|---|
#4 | FieldUiEDFRegions-v2.patch | 10.9 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedAlso this would help with adding layouts into the core later.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedFinally, I was able to get it working. Currently the form is lacking the same behavior as the Block layout form has which is moving the fields into proper regions when the region(in this case 'parent') fields is changed, so currently the user has to always drag the fields and I am a bit afraid of the
\Drupal\field_ui\Form\EntityDisplayFormBase::tablePreRender()
method, since I had a bit of trouble with figuring out how to make it work, that it will need refactoring later to be compatible with field group(module) since it kind of mixes "parent" and "region" terms.Also the region can be changed simply via hook_form_alter since they are copied into #regions attribute of the field ui table so making it work with layout_plugin is easy.
One last thing I have forgot is adding a #region attribute to each fields in the entity view so contrib modules can use that information when building the layout right away, just like the name of the view mode, instead of getting it from entity view mode's components again.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedAdded the region information for each field into entity view and hopefully the patch has now a proper format for testing.