I’ve create a form like:
function create_custom_form($form, &$form_state) {
$form['#action'] = "#";
....
}
function create_custom_form_validate($form, &$form_state) {
....
}
function create_custom_form_submit($form, &$form_state) {
....
if(..)
drupal_goto('abc');
else
drupal_goto('xxx');
}
when i submit this form drupal before go to action and after read my function… how I can bypass the action-form and read only a _submit function?
Do not use drupal_goto as there may be more “submit” callbacks to execute. The drupal_goto function will interrupt these.
Instead, use the
$form_state['redirect'] = ...http://api.drupal.org/api/drupal/includes!form.inc/function/drupal_redirect_form/7
As this function has the same form ID (
create_custom_form) – with the word “_submit” appended then this function will be executed automatically and so there is no need to add any submit callbacks into the form.If you want an additional function to execute on submit then you should do as Hamza has suggested, only your additional function will have a different name. e.g.
In the above example:
create_custom_form_additional_submit_callbackAND
create_custom_form_submit(because its got the same name with ‘_submit’ appended)will execute and only when they have both finished will the redirect be executed.