Url::validateUrl

public static Url::validateUrl(&$element, FormStateInterface $form_state, &$complete_form)

Form element validation handler for #type 'url'.

Note that #maxlength and #required is validated by _form_validate() already.

File

core/lib/Drupal/Core/Render/Element/Url.php, line 62

Class

Url
Provides a form element for input of a URL.

Namespace

Drupal\Core\Render\Element

Code

public static function validateUrl(&$element, FormStateInterface $form_state, &$complete_form) {
  $value = trim($element['#value']);
  $form_state->setValueForElement($element, $value);

  if ($value !== '' && !UrlHelper::isValid($value, TRUE)) {
    $form_state->setError($element, t('The URL %url is not valid.', array('%url' => $value)));
  }
}
doc_Drupal
2016-10-29 09:51:45
Comments
Leave a Comment

Please login to continue.