You are here

public function FixedTextLink::settingsForm in Fixed text link formatter 8

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

File

src/Plugin/Field/FieldFormatter/FixedTextLink.php, line 37

Class

FixedTextLink
Plugin implementation of the 'link' formatter.

Namespace

Drupal\fixed_text_link_formatter\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $parentForm, FormStateInterface $form_state) {
  $parentForm = parent::settingsForm($parentForm, $form_state);
  unset($parentForm['trim_length']);
  unset($parentForm['url_only']);
  unset($parentForm['url_plain']);
  $form['link_text'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Link text'),
    '#default_value' => $this
      ->getLinkText(),
    '#required' => TRUE,
  ];
  $form['link_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Link class'),
    '#default_value' => $this
      ->getLinkClass(),
    '#required' => FALSE,
  ];
  $form['allow_override'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t("Allow the title to be overridden"),
    '#default_value' => $this
      ->getSetting('allow_override'),
  ];
  return $form + $parentForm;
}