You are here

public function ExifWidgetBase::settingsForm in Exif 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/ExifWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase::settingsForm()

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

1 call to ExifWidgetBase::settingsForm()
ExifFieldWidgetBase::settingsForm in src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php
Returns a form to configure settings for the widget.
1 method overrides ExifWidgetBase::settingsForm()
ExifFieldWidgetBase::settingsForm in src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php
Returns a form to configure settings for the widget.

File

src/Plugin/Field/FieldWidget/ExifWidgetBase.php, line 60

Class

ExifWidgetBase
Base class for 'Exif Field widget' plugin implementations.

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  if ($form['#entity_type'] == "node" || $form['#entity_type'] == "media" || $form['#entity_type'] == "photos_image") {
    $image_fields = $this
      ->retrieveImageFieldFromBundle($form['#entity_type'], $form['#bundle']);
    $default_image_value = $this
      ->retrieveImageFieldDefaultValue($element, $image_fields);
    $element['image_field'] = [
      '#type' => 'radios',
      '#title' => t('image field to use to retrieve data'),
      '#description' => t('determine the image used to look for exif and iptc metadata'),
      '#options' => $image_fields,
      '#default_value' => $default_image_value,
      '#element_validate' => [
        [
          get_class($this),
          'validateImageField',
        ],
      ],
    ];
  }
  if ($form['#entity_type'] == "file") {
    $element['image_field'] = [
      '#type' => 'hidden',
      '#default_value' => "file",
      '#value' => "file",
    ];
  }
  return $element;
}