-1

I want to change the form action on form build. I tried with hook_form_alter() setting #action to '/page', but it doesn't work.

0
1

There are several triggers that can prevent $form['#action'] from working in an alter hook. See:

How to redirect to a page after submitting a form

For example, there is a no_redirect property:

FormState::$no_redirect

"If set to TRUE the form will NOT perform a redirect, even if self::$redirect is set."

You can test this with

$form_state->isRedirectDisabled()
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.