You are here

public static function IframeWidgetBase::validateWidth in Iframe 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/IframeWidgetBase.php \Drupal\iframe\Plugin\Field\FieldWidget\IframeWidgetBase::validateWidth()

Validate width(if minimum url is defined)

See also

\Drupal\Core\Form\FormValidator

File

src/Plugin/Field/FieldWidget/IframeWidgetBase.php, line 290

Class

IframeWidgetBase
Plugin implementation base functions.

Namespace

Drupal\iframe\Plugin\Field\FieldWidget

Code

public static function validateWidth(&$form, FormStateInterface &$form_state) {
  $me = IframeWidgetBase::getField($form, $form_state);

  // \iframe_debug(0, 'validateWidth', $me);
  if (!empty($me['url']) && isset($me['width'])) {
    if (empty($me['width']) || !preg_match('#^(\\d+\\%?|auto)$#', $me['width'])) {
      $form_state
        ->setError($form, self::getSizedescription());
    }
  }
}