7

I have added a custom form validation on node/add page in drupal 8. The purpose of adding this validator is to add a slash before the path alias string. By default if a path alias string is added without a slash then form validator gives an error asking to add a slash before string.

Now the problem is that the default validation is called before the custom validator.

The code have use is like :-

In my form_alter function

if (!is_array($form['#validate'])) {
  $form['#validate'] = array();
}
array_unshift($form['#validate'], 'my_custom_handler');

to add custom validator to the top of validate array.

Although, my custom validator is added to the top of validator array, still default validator is executing first.

Any help will be highly appreciated.

Thank you

1
  • 1
    Form element validation will always run first. Probably that could be your problem. On the otherhand could please elaborate more about the originalo issue? Standard Drupal installation shouldn't have this. Do you have any special contrib module, server settings, etc?
    – ssibal
    Commented Sep 17, 2018 at 14:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.