You are here

function ds_field_row_form_format_construct in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 includes/field_ui.inc \ds_field_row_form_format_construct()
  2. 8.3 includes/field_ui.inc \ds_field_row_form_format_construct()
  3. 7.2 includes/ds.field_ui.inc \ds_field_row_form_format_construct()

Helper function for building the formatter settings.

1 call to ds_field_row_form_format_construct()
_ds_field_ui_fields in includes/field_ui.inc
Add the fields to the Field UI form.

File

includes/field_ui.inc, line 1456
Field UI functions for Display Suite.

Code

function ds_field_row_form_format_construct(&$table, $key, $settings_form, FormStateInterface $form_state) {
  $build_info = $form_state
    ->getBuildInfo();
  $base_button = [
    '#submit' => [
      [
        $build_info['callback_object'],
        'multistepSubmit',
      ],
    ],
    '#validate' => [
      'ds_field_ui_fields_validate',
    ],
    '#ajax' => [
      'callback' => [
        $build_info['callback_object'],
        'multistepAjax',
      ],
      'wrapper' => 'field-display-overview-wrapper',
      'effect' => 'fade',
    ],
    '#field_name' => $key,
  ];
  $table[$key]['plugin']['settings_edit'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'field-plugin-settings-edit-form',
      ],
    ],
    '#parents' => [
      'fields',
      $key,
      'settings_edit_form',
    ],
    '#weight' => -5,
    // Create a settings form where hooks can pick in.
    'settings' => $settings_form,
    'actions' => [
      '#type' => 'actions',
      'save_settings' => $base_button + [
        '#type' => 'submit',
        '#name' => $key . '_plugin_settings_update',
        '#value' => t('Update'),
        '#op' => 'update',
      ],
      'cancel_settings' => $base_button + [
        '#type' => 'submit',
        '#name' => $key . '_plugin_settings_cancel',
        '#value' => t('Cancel'),
        '#op' => 'cancel',
        // Do not check errors for the 'Cancel' button.
        '#limit_validation_errors' => [],
      ],
    ],
  ];
  $table[$key]['#attributes']['class'][] = 'field-plugin-settings-editing';
  $table[$key]['plugin']['type']['#attributes']['class'] = [
    'visually-hidden',
  ];
}