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

Command icon 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

lauriii created an issue. See original summary.

lauriii’s picture

Status: Active » Needs review
Issue tags: +Needs change record updates, +Needs change record

I think we should create change record for this and update https://www.drupal.org/node/3364263 to reference it.

lauriii’s picture

Issue tags: -Needs change record

Added a draft CR.

alexpott’s picture

Status: Needs review » Needs work

Discussed 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.

lauriii’s picture

Issue summary: View changes
Status: Needs work » Needs review

Addressed #5 and tests are passing.

lauriii’s picture

Issue summary: View changes
lauriii’s picture

Issue summary: View changes

Renamed the alter hook based on feedback from @alexpott.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

https://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.

  • catch committed 502c857b on 11.x
    Issue #3408698 by lauriii, alexpott: Provide alter for the field type UI...

  • catch committed 5863929d on 10.2.x
    Issue #3408698 by lauriii, alexpott: Provide alter for the field type UI...
catch’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Asked @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!

lauriii’s picture

CR updates have been done.

wim leers’s picture

Issue tags: +Field UX

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.