public function ShortenShortenForm::validateForm in Shorten URLs 8
Same name and namespace in other branches
- 8.2 src/Form/ShortenShortenForm.php \Drupal\shorten\Form\ShortenShortenForm::validateForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ ShortenShortenForm.php, line 85
Class
- ShortenShortenForm
- Builds a form which allows shortening of a URL via the UI.
Namespace
Drupal\shorten\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$storage =& $form_state
->getStorage();
$url = $values['url_' . $storage['step']];
if (\Drupal\Component\Utility\Unicode::strlen($url) > 4) {
if (!strpos($url, '.', 1)) {
$form_state
->setErrorByName('url', $this
->t('Please enter a valid URL.'));
}
}
else {
$form_state
->setErrorByName('url', $this
->t('Please enter a valid URL.'));
}
}