function FieldUiTestHooks::formEntityViewDisplayEditFormAlter

Implements hook_form_FORM_BASE_ID_alter().

File

core/modules/field_ui/tests/modules/field_ui_test/src/Hook/FieldUiTestHooks.php, line 29

Class

FieldUiTestHooks
Hook implementations for field_ui_test.

Namespace

Drupal\field_ui_test\Hook

Code

public function formEntityViewDisplayEditFormAlter(&$form, FormStateInterface $form_state) : void {
    $table =& $form['fields'];
    foreach (Element::children($table) as $name) {
        $table[$name]['parent_wrapper']['parent']['#options'] = [
            'indent' => 'Indent',
        ];
        $table[$name]['parent_wrapper']['parent']['#default_value'] = 'indent';
    }
    $table['indent'] = [
        '#attributes' => [
            'class' => [
                'draggable',
                'field-group',
            ],
            'id' => 'indent-id',
        ],
        '#row_type' => 'group',
        '#region_callback' => 'field_ui_test_region_callback',
        '#js_settings' => [
            'rowHandler' => 'group',
        ],
        'human_name' => [
            '#markup' => 'Indent',
            '#prefix' => '<span class="group-label">',
            '#suffix' => '</span>',
        ],
        'weight' => [
            '#type' => 'textfield',
            '#default_value' => 0,
            '#size' => 3,
            '#attributes' => [
                'class' => [
                    'field-weight',
                ],
            ],
        ],
        'parent_wrapper' => [
            'parent' => [
                '#type' => 'select',
                '#options' => [
                    'indent' => 'Indent',
                ],
                '#empty_value' => '',
                '#default_value' => '',
                '#attributes' => [
                    'class' => [
                        'field-parent',
                    ],
                ],
                '#parents' => [
                    'fields',
                    'indent',
                    'parent',
                ],
            ],
            'hidden_name' => [
                '#type' => 'hidden',
                '#default_value' => 'indent',
                '#attributes' => [
                    'class' => [
                        'field-name',
                    ],
                ],
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.