You are here

public static function jCarouselFieldFormatter::jqueryCarouselSelectorValidate in jQuery carousel 8

Element validate; Check selector is valid.

File

src/Plugin/Field/FieldFormatter/jCarouselFieldFormatter.php, line 108

Class

jCarouselFieldFormatter
Plugin annotation @FieldFormatter( id = "jquery_carousel_images", label = @Translation("jQuery Carousel"), field_types = { "image" } )

Namespace

Drupal\jquery_carousel\Plugin\Field\FieldFormatter

Code

public static function jqueryCarouselSelectorValidate(array &$element, FormStateInterface $form_state) {
  $selector = $element['#value'];
  $error = _jquery_carousel_config_validate($selector);
  if ($error) {
    $form_state
      ->setErrorByName('selector', t("Selector should not contain any special characters or spaces. Only special character allowed is '-'"));
  }
}