Problem/Motivation

Just like in #2094499: Convert "Manage (form) display" forms to be the official entity edit forms for EntityView[Form]Display objects, we need to convert this Field UI form to D8.

This is also needed for #552604: Adding new fields leads to a confusing "Field settings" form, which is a usability improvement.

Proposed resolution

Do it.

Remaining tasks

None.

User interface changes

Nope.

API changes

The 'field_storage' form wrapper is removed from that form.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
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).

It also enables us to work on improving the usability of the "field add" form in #552604: Adding new fields leads to a confusing "Field settings" form.

Disruption Minor disruption for contrib modules that alter the "Edit field storage" Field UI form.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amateescu’s picture

Status: Active » Needs review
FileSize
31.6 KB

Something like this.

Status: Needs review » Needs work

The last submitted patch, 1: 2446869.patch, failed testing.

amateescu’s picture

Status: Needs work » Needs review
FileSize
32.68 KB
1.34 KB

Too much to ask for a green patch from the first try :/

andypost’s picture

Awesome! +1 rtbc
just a nit

+++ b/core/modules/field_ui/src/Form/FieldStorageEditForm.php
@@ -7,116 +7,87 @@
+  protected $entity;

is this for type hinting? entity form already have this one defined

amateescu’s picture

Yup, it's just for type hinting. I don't link to put those /** @var \Stuff $stuff all over the place :)

amateescu’s picture

FileSize
32.58 KB

Reroll and bump.

amateescu’s picture

Issue summary: View changes
yched’s picture

Those two patches are definitely on my radar, didn't have a chance to get to them so far.

@amateescu+++++++

amateescu’s picture

FileSize
33.58 KB
1.58 KB

No worries, I have enough other things to work on in the meantime :)

Let's update the class name for the form to include the full name of the entity type, like in #2448503: Convert the "Field edit" form to an actual entity form.

amateescu’s picture

+++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
@@ -2,121 +2,92 @@
+      $field = FieldConfig::load($field_config);
+      $form_state->set('field_config', $field);

This is probably one of the things that you will point out: "why do we still need to keep this around?", and it's because field storage config still doesn't have a label of its own so we need to use the field config label for $form['#prefix'] and the drupal_set_message() text.

I'm already fixing that in the in-progress patch for #552604: Adding new fields leads to a confusing "Field settings" form by adding a label property to field storages, but maybe we should open a separate issue for it.. or just fix it here?

The last submitted patch, 6: 2446869-6.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2446869-9.patch, failed testing.

amateescu queued 9: 2446869-9.patch for re-testing.

The last submitted patch, 9: 2446869-9.patch, failed testing.

amateescu’s picture

Status: Needs work » Needs review
FileSize
36.34 KB
1.17 KB

Fixed the fail and another small problem found while I was there.

yched’s picture

No time to look into the actual FieldStorageConfigEditForm tonight, just looked at the surroundings ;-)

  1. +++ b/core/modules/comment/src/Tests/CommentFieldsTest.php
    @@ -129,7 +129,7 @@ public function testCommentFieldCreate() {
    -      'field_storage[settings][comment_type]' => 'user_comment_type',
    +      'settings[comment_type]' => 'user_comment_type',
    

    <3

  2. +++ b/core/modules/field_ui/src/Routing/RouteSubscriber.php
    @@ -79,8 +79,8 @@ protected function alterRoutes(RouteCollection $collection) {
    -          array('_form' => '\Drupal\field_ui\Form\FieldStorageEditForm') + $defaults,
    -          array('_entity_access' => 'field_config.update'),
    +          array('_entity_form' => 'field_storage_config.edit') + $defaults,
    +          array('_permission' => 'administer ' . $entity_type_id . ' fields'),
    

    Wondering about this - should entity forms use entity access or dedicated permissions directly ?

    Even though the current code is definitely weird :
    - FieldStorageConfig currently defines no access handler
    - the existing routing code "borrows" *field_config*.update for this route about *field_storage_config*
    - field_config does define an access handler, FieldConfigAccessControlHandler, which grants access based on the "administer [entity_type] fields'

    I'm +++ on bringing some sanity here, just wondering whether we should stay with the entity access on the route and add a proper FieldStorageConfigAccessControlHandler ?

amateescu’s picture

I actually tried that when I was working on the "Field UI sanity" patch but the problem is that access checking only works with the entities that are part of the route (parameters), and, in this case, field_storage_config is not, only field_config is :/

amateescu’s picture

FileSize
33.68 KB
651 bytes

Small self-review.

jibran’s picture

I think it's ready just two minor nits.

  1. +++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
    @@ -2,121 +2,92 @@
    +    $ids = (object) array('entity_type' => $form_state->get('entity_type_id'), 'bundle' => $form_state->get('bundle'), 'entity_id' => NULL);
    
  2. Can we change it to multi line now?
    +++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
    @@ -2,121 +2,92 @@
    +  public function buildForm(array $form, FormStateInterface $form_state, $field_config = NULL) {
    

    $field_config typehinting missing and function doc also needs update.

amateescu’s picture

FileSize
33.82 KB
1.32 KB

1. Not introduced by this issue, but why not.
2. Fixed the method doc.

jibran’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
39.79 KB

I manually tested the patch everything was working fine. So RTBC


I didn't know delete field page was showing 'Configuration updates' details so this is same in the HEAD and with this patch of course we are not doing anything with delete form in this issue.

amateescu’s picture

Status: Reviewed & tested by the community » Needs review

@yched said he wants to review this patch so there's no rush for RTBC.

yched’s picture

Status: Needs review » Reviewed & tested by the community

No additional remarks for FieldStorageConfigEditForm, except :

+++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
@@ -144,79 +122,70 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf
-    // Build the non-configurable field values.
-    $form['field_storage']['field_name'] = array('#type' => 'value', '#value' => $field_storage->getName());
-    $form['field_storage']['type'] = array('#type' => 'value', '#value' => $field_storage->getType());
-    $form['field_storage']['module'] = array('#type' => 'value', '#value' => $field_storage->getTypeProvider());
-    $form['field_storage']['translatable'] = array('#type' => 'value', '#value' => $field_storage->isTranslatable());

oh, yeah, these have been useless since probably CCK D6 :-)

RTBC +1

amateescu’s picture

OMG, could this be the first "yched nitpick free" patch I ever wrote?! Feeling so proud right now :D

yched’s picture

Hah ! I *knew* you'd say that :-p

amateescu’s picture

I'm so predictable :/

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

UX improvements to field UI - yep we want that. Committed 030f536 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed 030f536 on 8.0.x
    Issue #2446869 by amateescu: Convert the "Field storage edit" form to an...

Status: Fixed » Closed (fixed)

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