You are here

public function BynderDocumentFormatter::settingsForm in Bynder 8.3

Same name and namespace in other branches
  1. 4.0.x src/Plugin/Field/FieldFormatter/BynderDocumentFormatter.php \Drupal\bynder\Plugin\Field\FieldFormatter\BynderDocumentFormatter::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 FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/BynderDocumentFormatter.php, line 35

Class

BynderDocumentFormatter
Plugin implementation of the 'Bynder Document' formatter.

Namespace

Drupal\bynder\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);
  $elements['link'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Render as link'),
    '#description' => $this
      ->t('Whether the URL should be shown as a link or just as a plain URL.'),
    '#default_value' => $this
      ->getSetting('link'),
  ];
  $field_candidates = $this
    ->getAttributesFieldsCandidates();
  $elements['title_field'] = [
    '#type' => 'select',
    '#options' => $field_candidates,
    '#title' => $this
      ->t('Link Title field'),
    '#description' => $this
      ->t('Select the name of the field that should be used for the link title. Falls back to the name of the file if not set.'),
    '#default_value' => $this
      ->getSetting('title_field'),
    '#empty_option' => $this
      ->t('- File name -'),
  ];
  return $elements;
}