You are here

public function RemoteImageWidget::settingsForm in Remote image 8

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.

Overrides LinkWidget::settingsForm

File

src/Plugin/Field/FieldWidget/RemoteImageWidget.php, line 43
Contains Drupal\remote_image\Plugin\Field\FieldWidget\RemoteImageWidget.

Class

RemoteImageWidget
Plugin implementation of the 'remote_image' widget.

Namespace

Drupal\remote_image\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  // Get the field settings.
  $field_settings = $this->fieldDefinition
    ->getSettings();
  $elements = parent::settingsForm($form, $form_state) + [
    'placeholder_alt' => !$field_settings['alt_field'] ? [] : [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Placeholder for alt text'),
      '#default_value' => $this
        ->getSetting('placeholder_alt'),
      '#description' => $this
        ->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
    ],
  ];
  $elements['placeholder_title'] = !$field_settings['title_field'] ? [] : [
    '#title' => $this
      ->t('Placeholder for image title'),
    '#states' => [],
  ] + $elements['placeholder_title'];
  return $elements;
}