You are here

public function EntityReferenceTableFormatter::settingsForm in Reference Table Formatter 2.0.x

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/EntityReferenceTableFormatter.php, line 113

Class

EntityReferenceTableFormatter
A field formatter to display a table.

Namespace

Drupal\reference_table_formatter\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form['view_mode'] = [
    '#title' => $this
      ->t('View Mode'),
    '#description' => $this
      ->t('Select the view mode which will control which fields are shown and the display settings of those fields.'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('view_mode'),
    '#options' => $this
      ->getConfigurableViewModes(),
  ];
  $form['show_entity_label'] = [
    '#title' => $this
      ->t('Display Entity Label'),
    '#description' => $this
      ->t('Whether the label of the target entity be displayed in the table.'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('show_entity_label'),
  ];
  $form['hide_header'] = [
    '#title' => $this
      ->t('Hide Table Header'),
    '#description' => $this
      ->t('Whether the table header be displayed.'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('hide_header'),
  ];
  $form['empty_cell_value'] = [
    '#title' => $this
      ->t('Empty Cell Value'),
    '#description' => $this
      ->t('The string which should be displayed in empty cells.'),
    '#type' => 'textfield',
    '#default_value' => $this
      ->getSetting('empty_cell_value'),
  ];
  return $form;
}