I've embedded a node/add form on my homepage for submissions but for caching purposes, I need to have any server-side validation occur on a different page instead of itself.

I.e. If the form fails server-side validation, it returns me to the index page. INSTEAD, I'd like it to go to some other page, like /form-error and display the error there with the form below to fix the error.


The problem with that is you're going to loose form state redirecting to your custom /form-error form. One solution is to duplicate your embedded node/add form at /error-form (build via hook_menu & drupal_get_form). Then modify your embedded frontpage node/add form to submit at /error-form.

$form['#action'] = url('error-form');

Lastly, modify your node/add form submission handler to go wherever you need it to on a successful submission (instead of /error-form)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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