You are here

public function ExifFieldWidgetBase::settingsForm in Exif 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifFieldWidgetBase::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 ExifWidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php, line 64

Class

ExifFieldWidgetBase
Class ExifFieldWidgetBase provide base methods for all widgets.

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $exif_fields = $this
    ->retrieveExifFields();
  $default_exif_value = $this
    ->retrieveExifFieldDefaultValue();
  $default_exif_separator_value = $this
    ->retrieveExifFieldDefaultSeparatorValue();
  $element['exif_field'] = [
    '#type' => 'select',
    '#title' => t('exif field data'),
    '#description' => t('choose to retrieve data from the image field referenced with the selected name or by naming convention.'),
    '#options' => array_merge([
      'naming_convention' => 'name of the field is used as the exif field name',
    ], $exif_fields),
    '#default_value' => $default_exif_value,
    '#element_validate' => [
      [
        get_class($this),
        'validateExifField',
      ],
    ],
  ];
  $element['exif_field_separator'] = [
    '#type' => 'textfield',
    '#title' => t('exif field separator'),
    '#description' => t('separator used to split values (if field definition support several values). let it empty if you do not want to split values.'),
    '#default_value' => $default_exif_separator_value,
    '#element_validate' => [
      [
        get_class($this),
        'validateExifFieldSeparator',
      ],
    ],
  ];
  return $element;
}