You are here

public function PhoneLinkFieldFormatter::settingsForm in Phone link 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 FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/PhoneLinkFieldFormatter.php, line 54

Class

PhoneLinkFieldFormatter
Plugin implementation of the 'phone_link_field_formatter' formatter.

Namespace

Drupal\phone_link\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements['title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Title tip'),
    '#description' => $this
      ->t('Provide "title" HTML-attribute for phone link. You can use "@phone" replacement (without quotes).'),
    '#default_value' => $this
      ->getSetting('title'),
  ];
  $elements['text'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Replace phone number'),
    '#description' => $this
      ->t('Text displayed instead of phone. You can use "@phone" replacement (without quotes).'),
    '#default_value' => $this
      ->getSetting('text'),
  ];
  $elements['type'] = [
    '#type' => 'select',
    '#options' => $this
      ->getPhoneTypes(),
    '#title' => $this
      ->t('Type of link'),
    '#description' => $this
      ->t('Choose the type of phone link. Default phones: "tel:", or Skype-format "callto:".'),
    '#default_value' => $this
      ->getSetting('type'),
  ];
  return $elements;
}