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

Ensure field is correctly configured.

Parameters

array $element: A form element array containing basic properties for the widget.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $form: The form structure where widgets are being attached to.

File

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

Class

ExifFieldWidgetBase
Class ExifFieldWidgetBase provide base methods for all widgets.

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

public static function validateExifField(array $element, FormStateInterface $form_state, array $form) {
    $elementSettings = $form_state->getValue($element['#parents']);
    if (!$elementSettings) {
        $message = t('you must choose at least one method to retrieve image metadata.');
        $form_state->setErrorByName('exif_field', $message);
    }
}