Problem/Motivation

Many modules are defining alter hooks to alter the cardinality form for a field type provided by the same module. There's pre-existing API to modify the field storage form from field types, but it hasn't been possible to modify the cardinality form through that because it's added to the form too late.

Proposed resolution

Add cardinality form to the field storage before the settings form in \Drupal\field_ui\Form\FieldStorageConfigEditForm::form to allow field types to override it without defining an alter hook.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3391912

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

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Only rebased to run test-only run and worked like a charm.

1) Drupal\Tests\field_ui\Functional\ManageFieldsTest::testFieldTypeCardinalityAlter
Behat\Mink\Exception\ElementTextException: The text "Greetings from Drupal\field_test\Plugin\Field\FieldType\TestItem::storageSettingsForm" was not found in the text of the element matching css "#edit-field-storage".
/builds/issue/drupal-3391912/vendor/behat/mink/src/WebAssert.php:847
/builds/issue/drupal-3391912/vendor/behat/mink/src/WebAssert.php:467
/builds/issue/drupal-3391912/core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php:345
/builds/issue/drupal-3391912/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

Reviewing change and seems pretty simple moving the getCardinalityForm up some.

LGTM.

smustgrave’s picture

Saving credit for @lauriii for the actual work.

nod_ made their first commit to this issue’s fork.

  • nod_ committed d2080999 on 11.x
    Issue #3391912 by lauriii: Allow field types to override the cardinality...
nod_’s picture

Status: Reviewed & tested by the community » Fixed

Committed d208099 and pushed to 11.x. Thanks!

  • nod_ committed 4280bf15 on 10.2.x
    Issue #3391912 by lauriii: Allow field types to override the cardinality...

Status: Fixed » Closed (fixed)

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