Same name and namespace in other branches
  1. 8.x-2.x src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifFieldWidgetBase::settingsForm() 1 comment

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;
}