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

Ensure field separator 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.

File

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

Class

ExifFieldWidgetBase
Class ExifFieldWidgetBase provide base methods for all widgets.

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

public static function validateExifFieldSeparator(array $element, FormStateInterface &$form_state) {
    $elementSettings = $form_state->getValue($element['#parents']);
    if (!empty($elementSettings) && strlen($elementSettings) > 1) {
        $message = t('the separator is only one character long.');
        $form_state->setErrorByName('exif_field_separator', $message);
    }
}