You are here

public function ButtonFieldImage::settingsForm in Button Field 8

Same name in this branch
  1. 8 src/Plugin/Field/FieldFormatter/ButtonFieldImage.php \Drupal\button_field\Plugin\Field\FieldFormatter\ButtonFieldImage::settingsForm()
  2. 8 src/Plugin/Field/FieldWidget/ButtonFieldImage.php \Drupal\button_field\Plugin\Field\FieldWidget\ButtonFieldImage::settingsForm()

@todo Provide a file upload element.

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/ButtonFieldImage.php, line 40
Contains Drupal\button_field\Plugin\Field\FieldFormatter\ButtonFieldImage.

Class

ButtonFieldImage
Plugin implementation of the 'image button' field formatter.

Namespace

Drupal\button_field\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $element['image_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Image path'),
    '#default_value' => $this
      ->getSetting('image_path'),
    '#required' => TRUE,
  );
  $element['alt_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Alt text'),
    '#default_value' => $this
      ->getSetting('alt_text') ?: $this->fieldDefinition
      ->getLabel(),
    '#required' => TRUE,
  );
  $element['title_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Title text'),
    '#default_value' => $this
      ->getSetting('title_text'),
    '#required' => FALSE,
  );
  return $element;
}