Problem/Motivation
The Field UX work is changing the form structures. One of the valid use cases we realized can currently achieved only by altering the form was modifying field types available through the UI for a specific entity type. For example, comment module is disabling the comment field type from entity types that are not compatible with the comment module. Doing this via form alter is brittle, in particular now that we are introducing changes to the Field UI.
Proposed resolution
#3386762: Use modals in field creation and field edit flow approached this by providing a new alter for the field type UI definitions, that allows altering the field type UI definitions dynamically depending on the entity type. However, this was done directly in the Field UI. This issue is proposing to do this in \Drupal\Core\Field\FieldTypePluginManager by adding a new method so that this information is available to other UIs without having to explicitly trigger the alter hook.
Remaining tasks
User interface changes
API changes
New alter hook: hook_field_info_entity_type_ui_definitions_alter.
New method to retrieve the UI definitions per entity type: \Drupal\Core\Field\FieldTypePluginManagerInterface::getEntityTypeUiDefinitions
Data model changes
Release notes snippet
Issue fork drupal-3408698
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
lauriiiI think we should create change record for this and update https://www.drupal.org/node/3364263 to reference it.
Comment #4
lauriiiAdded a draft CR.
Comment #5
alexpottDiscussed with @lauriii and we think that adding
\Drupal\Core\Field\FieldTypePluginManagerInterface::getUiDefinitionsForEntityType($entity_type_id);is better than burying this alter in field_ui code.Comment #6
lauriiiAddressed #5 and tests are passing.
Comment #7
lauriiiComment #8
lauriiiRenamed the alter hook based on feedback from @alexpott.
Comment #9
alexpotthttps://git.drupalcode.org/project/drupal/-/merge_requests/5802/diffs?co... proves we have good test coverage of comment's usage so that's nice!
I think adding this to the Field type manager is good because burying it in the field UI module would make it hard to discover and trickier for anything building field ui improvements in contrib.
Comment #13
catchAsked @lauriii for a 10.2.x version without any interface changes or deprecations for 10.2.x, and committed the respective patches to each branch, thanks!
Comment #16
lauriiiCR updates have been done.
Comment #17
wim leers