0

I've attached a Process button on the node edit form. But on clicking it - in it's validation function form_set_error is not working.

In my form_alter I've this code:

$form['buttons']['process'] = array(
            '#type' => 'submit',
            '#value' => 'Process',
            '#validate' => array('disavow_process_validate'),
        );

        $form['#validate'][] = 'disavow_validate';

So on pressing "Process" button validator function disavow_process_validate is called with $form and &$form_state. But form_set_error and assigning values in the $form_state are not working as working in the normal validation function disavow_validate

What could be the problem?

1 Answer 1

1
+50

See below example which works perfectly...

function drup_custom_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == "page_node_form" && arg(2) == "edit") {
    $form['buttons']['process'] = array(
            '#type' => 'submit',
            '#value' => 'Process',
            '#validate' => array('disavow_process_validate'),
    );
  }
}

function disavow_process_validate($form, &$form_state) {
  form_set_error('title', 'Something wrong here !');
}

Please update what you are trying to do inside validate function..

1
  • Sorry it was some typo.
    – AgA
    Apr 9, 2014 at 9:52

Your Answer

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

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