You are here

public function HtmlList::settingsForm in Double Field 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldFormatter/HtmlList.php \Drupal\double_field\Plugin\Field\FieldFormatter\HtmlList::settingsForm()

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 ListBase::settingsForm

File

src/Plugin/Field/FieldFormatter/HtmlList.php, line 29

Class

HtmlList
Plugin implementations for 'html_list' formatter.

Namespace

Drupal\double_field\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) : array {
  $element['list_type'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('List type'),
    '#options' => [
      'ul' => $this
        ->t('Unordered list'),
      'ol' => $this
        ->t('Ordered list'),
      'dl' => $this
        ->t('Definition list'),
    ],
    '#default_value' => $this
      ->getSetting('list_type'),
  ];
  $element += parent::settingsForm($form, $form_state);
  $field_name = $this->fieldDefinition
    ->getName();
  $element['inline']['#states']['invisible'] = [
    ":input[name='fields[{$field_name}][settings_edit_form][settings][list_type]']" => [
      'value' => 'dl',
    ],
  ];
  return $element;
}