function EntityViewDisplayEditForm::buildFieldRow

Same name in other branches
  1. 9 core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php \Drupal\field_ui\Form\EntityViewDisplayEditForm::buildFieldRow()
  2. 10 core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php \Drupal\field_ui\Form\EntityViewDisplayEditForm::buildFieldRow()
  3. 11.x core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php \Drupal\field_ui\Form\EntityViewDisplayEditForm::buildFieldRow()

Overrides EntityDisplayFormBase::buildFieldRow

1 call to EntityViewDisplayEditForm::buildFieldRow()
LayoutBuilderEntityViewDisplayForm::buildFieldRow in core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php
Builds the table row structure for a single field.
1 method overrides EntityViewDisplayEditForm::buildFieldRow()
LayoutBuilderEntityViewDisplayForm::buildFieldRow in core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php
Builds the table row structure for a single field.

File

core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php, line 39

Class

EntityViewDisplayEditForm
Edit form for the EntityViewDisplay entity type.

Namespace

Drupal\field_ui\Form

Code

protected function buildFieldRow(FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
    $field_row = parent::buildFieldRow($field_definition, $form, $form_state);
    $field_name = $field_definition->getName();
    $display_options = $this->entity
        ->getComponent($field_name);
    // Insert the label column.
    $label = [
        'label' => [
            '#type' => 'select',
            '#title' => $this->t('Label display for @title', [
                '@title' => $field_definition->getLabel(),
            ]),
            '#title_display' => 'invisible',
            '#options' => $this->getFieldLabelOptions(),
            '#default_value' => $display_options ? $display_options['label'] : 'above',
        ],
    ];
    $label_position = array_search('plugin', array_keys($field_row));
    $field_row = array_slice($field_row, 0, $label_position, TRUE) + $label + array_slice($field_row, $label_position, count($field_row) - 1, TRUE);
    // Update the (invisible) title of the 'plugin' column.
    $field_row['plugin']['#title'] = $this->t('Formatter for @title', [
        '@title' => $field_definition->getLabel(),
    ]);
    if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $this->entity
        ->getRenderer($field_name))) {
        $plugin_type_info = $plugin->getPluginDefinition();
        $field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Format settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';
    }
    return $field_row;
}

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