public function SignupForm::validateForm in SendinBlue 8
Same name and namespace in other branches
- 8.2 src/Form/SignupForm.php \Drupal\sendinblue\Form\SignupForm::validateForm()
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level validation handler, otherwise an exception will be thrown.
Overrides ContentEntityForm::validateForm
File
- src/
Form/ SignupForm.php, line 384
Class
- SignupForm
- Form controller for the content_entity_example entity edit forms.
Namespace
Drupal\sendinblue\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this
->buildEntity($form, $form_state);
$path = $form_state
->getValue([
'path',
]);
$redirect_url = $form_state
->getValue([
'subscription',
'settings',
'redirect_url',
]);
if (!empty($path) && UrlHelper::isExternal($path)) {
$form_state
->setErrorByName('path', 'The path "' . $path . '" for Display Mode is invalid. You have to put a valid internal path.');
return;
}
if (!empty($redirect_url) && UrlHelper::isExternal($redirect_url)) {
$form_state
->setErrorByName('redirect_url', 'The redirect_url "' . $redirect_url . '" for SUBSCRIPTION is invalid. You have to put a valid internal path.');
return;
}
return $entity;
}