I have a form with 2 buttons. One is a submit button and another is a simple button when clicked, the page has to be redirected to another page.(I mean the user has to be redirected even if he hasn't filled in the entire form)
So after the submit button I put the following code for the other element
<?php $form['health_calorie_consume']['view'] = array( '#type'=>'button', '#value'=>'View stats', '#validate'=>array('mymodule_form_view'), ); ?>
inside the mymodule_form_view() function, I put the below code,
<?php function mymodule_form_view() $form_state['redirect'] = 'http://localhost/d7/?q=node/3'; ?>
To my surprise, Thhe function gets called but its not redirected..! and shows errors that some of the form fields with
#reuired attribute haven't been filled out..! I tried using
drupal_goto()function, it redirects to the other page properly but even in the redirected page those, "required" errors show up..!!
I even tried making #required attributes FALSE, inside the
mymodule_form_view()and yet it didn't work.
So how to solve this problem..??