public static function IframeWidgetBase::validateUrl in Iframe 8.2
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldWidget/IframeWidgetBase.php \Drupal\iframe\Plugin\Field\FieldWidget\IframeWidgetBase::validateUrl()
Validate url.
See also
\Drupal\Core\Form\FormValidator
File
- src/
Plugin/ Field/ FieldWidget/ IframeWidgetBase.php, line 322
Class
- IframeWidgetBase
- Plugin implementation base functions.
Namespace
Drupal\iframe\Plugin\Field\FieldWidgetCode
public static function validateUrl(&$form, FormStateInterface &$form_state) {
$me = IframeWidgetBase::getField($form, $form_state);
$testabsolute = true;
// \iframe_debug(0, 'validateUrl', $me);
if (!empty($me['url'])) {
if (preg_match('#^/($|[^/])#', $me['url'])) {
$testabsolute = false;
}
if (!UrlHelper::isValid($me['url'], $testabsolute)) {
$form_state
->setError($form, t('Invalid syntax for "Iframe URL".'));
}
elseif (strpos($me['url'], '//') === 0) {
$form_state
->setError($form, t('Drupal does not accept scheme-less URLs. Please add "https:" to your URL, this works on http-parent-pages too.'));
}
}
}