You are here

public static function FocalPointImageWidget::validateFocalPoint in Focal Point 8

Validation Callback; Focal Point process field.

1 call to FocalPointImageWidget::validateFocalPoint()
FocalPointImageWidget::validateFocalPointWidget in src/Plugin/Field/FieldWidget/FocalPointImageWidget.php
Validation Callback; Focal Point widget setting.

File

src/Plugin/Field/FieldWidget/FocalPointImageWidget.php, line 206

Class

FocalPointImageWidget
Plugin implementation of the 'image_focal_point' widget.

Namespace

Drupal\focal_point\Plugin\Field\FieldWidget

Code

public static function validateFocalPoint($element, FormStateInterface $form_state) {
  if (empty($element['#value']) || FALSE === \Drupal::service('focal_point.manager')
    ->validateFocalPoint($element['#value'])) {
    $replacements = [
      '@title' => strtolower($element['#title']),
    ];
    $form_state
      ->setError($element, new TranslatableMarkup('The @title field should be in the form "leftoffset,topoffset" where offsets are in percentages. Ex: 25,75.', $replacements));
  }
}