Archive for February, 2014

Disable form validation on ajax call in Drupal form

If you use multiple submit button in Drupal from and add ajax call to submit button then you ajax submit button will execute form default validate and submit function. To prevent it from calling those default function you just need to do two following steps.

1) rename my validation function from “myformname_validate” to “myformname_do_validate”. This caused my validate function to not be called during the ajax request.

2) attach the “myformname_do_validate” function to my submit button like so:

$form[‘submit’] = array(
‘#type’ => ‘submit’,
‘#value’ => t(‘Submit’),
‘#validate’ => array(‘myformname__do_validate’),

, ,

Leave a comment