public static function IframeWidgetBase::validateHeight in Iframe 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/IframeWidgetBase.php \Drupal\iframe\Plugin\Field\FieldWidget\IframeWidgetBase::validateHeight()
Validate height (if minimum url is defined)
See also
\Drupal\Core\Form\FormValidator
File
- src/Plugin/ Field/ FieldWidget/ IframeWidgetBase.php, line 314 
Class
- IframeWidgetBase
- Plugin implementation base functions.
Namespace
Drupal\iframe\Plugin\Field\FieldWidgetCode
public static function validateHeight(&$form, FormStateInterface &$form_state) {
  $parents = $form['#parents'];
  $itemfield = $parents[0];
  $iteminst = $parents[1];
  /*
   * $value = $form['#value'];
   * $itemname = $parents[2];
   * $itemid = $form['#id'];
   */
  $node = $form_state
    ->getUserInput();
  $me = $node[$itemfield][$iteminst];
  // \iframe_debug(0, 'validateHeight', $me);
  if (!empty($me['url']) && isset($me['height'])) {
    if (empty($me['height']) || !preg_match('#^(\\d+\\%?|auto)$#', $me['height'])) {
      $form_state
        ->setError($form, self::getSizedescription());
    }
  }
}