1

I have a problem using #limit_validation_errors for a submit button on which I dont want all the validations to run. Here's my custom submit button :

$form['actions']['draft'] = array(
     '#type' => 'submit',
     '#value' => 'Save as draft',
     '#submit' => array(''),
     '#limit_validation_errors' => array(
       array('title'), // Validate $form_state['values']['title'].
     ),
);

It works perfectly in the sense that it checks the validation on the title field only, but the weird thing is, it does not submit any other field's values when submitted. I wrote a custom submit handler to check that. However, the values are present in $form_state['input'] but not in $form_state['values'].

What I want simply is, this form will submit with just the values given and overlook the validations when this custom submit button is clicked.

FYI : I can get $form_state['values'] perfectly in my custom validate function.

Any ideas? What am I doing wrong here?

1

It works as expected - in $form_state['values'] you have validated values, and in $form_state['input'] you have raw values. If you will limit validation to title field only - only this field will be transferred into "values" array.

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.