I have a content type on which I added a custom validation that there can't be more than 7 items of that content type that is marked as 'sticky'. That validation was added on the add and edit pages through omhm_mod_form_blog_node_form_alter(&$form, &$form_state, $form_id) with the line $form['#validate'][] = 'omhm_mod_form_nouvelle_node_form_validate'; and my custom validation omhm_mod_form_nouvelle_node_form_validate.

Now I have to make a page with views bulk operations with the same custom validation in place ... how can I do that ?

I'm trying to add the custom vbo validation views_bulk_operations_form_validate($form, &$form_state) to my omhm_mod_views_bulk_operations_form_alter($form, &$form_state, $form_id) hook with the line $form['select']['submit']['#validate'][] = 'omhm_mod_carrousel_views_bulk_operations_form_validate'; but nothing happens.

1 Answer 1


Your omhm_mod_views_bulk_operations_form_alter($form, &$form_state, $form_id) takes $form by value, not by reference, so any changes made to $form are scoped to the function only. That's why $form['select']['submit']['#validate'][] changes nothing. It should be omhm_mod_views_bulk_operations_form_alter(&$form, &$form_state, $form_id)

When you fix mistake I pointed above, and it will not help, be sure to test if your hook is run at all, and if it is, then test if your validator is. It'll be needed for your next question, if you will need to ask it.

  • Yep, you're totally right ... dumb mistake on my part. I modified the default error messages in the custom validation function and the modified messages appear when I submit the vbo form. Just have to add my other validations now ... Thanks !
    – agodin
    Aug 25, 2014 at 20:47

Your Answer

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

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