Problem/Motivation
Just like in #2094499: Convert "Manage (form) display" forms to be the official entity edit forms for EntityView[Form]Display objects and #2446869: Convert the "Field storage edit" form to an actual entity form, we need to convert this Field UI form to D8.
Proposed resolution
Do it.
Remaining tasks
Review #2448357: Config entity forms need to have access to an updated entity object at all times first.
User interface changes
Nope.
API changes
The 'field form wrapper is removed from that form.
Beta phase evaluation
| Issue category | Task because the current form is not broken. |
|---|---|
| Prioritized changes | The main goal of this issue is to convert one Field UI form to the new API available in Drupal 8 (the EntityForm base class). |
| Disruption | Minor disruption for contrib modules that alter the "Field edit" Field UI form. |
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2448503-18.patch | 45.99 KB | amateescu |
| #17 | 2448503-17.patch | 46.11 KB | amateescu |
| #11 | interdiff.txt | 6.06 KB | amateescu |
| #11 | 2448503-11.patch | 46.42 KB | amateescu |
| #7 | interdiff.txt | 10.27 KB | amateescu |
Comments
Comment #1
amateescu commentedInitial patch, it won't pass until #2448357: Config entity forms need to have access to an updated entity object at all times gets in.
Comment #2
amateescu commentedNow rolled with -M25% because the form class changes a lot.
Comment #5
amateescu commentedThe blocker went in. Hopefully, we won't have any other test fails :)
Comment #7
amateescu commentedFixed all that.
Comment #9
jibranSome awesome work. Just two nits.
We have
$this->entityManagerinEntityFormwe can replace this with$this->entityManager->getBundleInfo($entity_type);Please change this to multi line.
Comment #10
yched commentedAweome, just like #2446869: Convert the "Field storage edit" form to an actual entity form, this removes a lot of weirdness.
This was just added by #2448357: Config entity forms need to have access to an updated entity object at all times - but we actually need both checks ? The comment above needs to be adjusted then ?
What would be a case of having a $default_values[N] that doesn't have a 'target_id' ?
(and how is that revealed by / related to this patch ?)
HEAD is actually lying anyway - the settingsForm() for widgets and formatters are invoked by the Display forms, right ?
<3, like in the other issue :-D
Cool indeed !
Feels weird that this is both calling the parent and re-doing all over again what it does for the 'delete' button, with just a different $url ? Can't we just override $actions['delete']['#url'], just like we simply override $actions['submit']['#value'] above ?
(also, double empty line)
Comment #11
amateescu commented#9.1 and 2: Fixed.
#10.1 and 2: Because I was dumb and I broke the default_value handling by putting it in
buildEntity(). Moved it to where it should be (insubmitForm()) and everything works again with the changes to EntityForm and EntityReferenceFieldItemList reverted.#10.3: Fixed.
#10.4 and 5: Awesomesauce :D
#10.6: That's because the parent method will only generate the delete element if the entity has a 'delete-form' link template, and field_config doesn't have one :/
Comment #12
yched commentedFair enough. Isn't that something we'd want to add ? :-) We do add them for view_mode & form_mode config entity types.
(probably not striclty related to this patch though...)
Related - field_ui's job of "decorate the 4 core entity types (field, field_storage, view_mode, form_mode)" seems a bit randomly split between field_ui_entity_type_build() and field_ui_entity_type_alter() 200 lines lower.
The usual rule of thumb is "hook_*_build() is to add stuff that's not there, hook_*_alter() is to modify what's already there", right ? So it should all go in field_ui_entity_type_build() ?
(also not srtricly related to this patch here - followup once this one and its sister issue are in ?)
Comment #13
jibranShould we wait for #2446869: Convert the "Field storage edit" form to an actual entity form?
Comment #14
amateescu commentedWe actually had them until recently, but, since we've converted most of Field UI to entity forms, they don't work anymore because
Drupal\Core\Entity\Entity::urlInfo()is doing some hardcoding on link template -> route name + parameters.Also, view modes and form modes can have link templates because they have a fixed path (e.g. /admin/structure/display-modes/form/manage/{entity_form_mode}), but field storage config, field config and entity displays have dynamic paths that vary by
field_ui_base_route.Very good point! Although, the hook_*_build() in this case is meant for "adding something new on the top level" afaik, (e.g. a new entity type definition that's not in code, for example what ECK will use), so what we're currently doing in
field_ui_entity_type_build()should move tofield_ui_entity_type_alter()because we're just altering the definition of already existing entity types.Comment #15
yched commentedRight, makes sense. Thanks for the explanation :-)
Opened #2459949: Remove field_ui_entity_type_alter() and move the content to field_ui_entity_type_build() - this patch here should be good to go.
Comment #17
amateescu commentedRerolled.
Comment #18
amateescu commentedYAR after #2446869: Convert the "Field storage edit" form to an actual entity form.
Comment #19
alexpottCommitted 95dc317 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.