In my modules hook_form_alter I add a validation hook: array_unshift($form['#validate'], 'change_node_form_domain_selection_to_array');
but when workbench is enabled, this function is not executed.

Comments

eMuse_be’s picture

Title: Validate hook is thrown away by workbench » When workbench_moderation is enabled by features, it breaks.

So, I enabled workbench using a feature dependency.
I also have a custom module with a hook_form_alter that adds a validaiton hook to a form which worked fine. When workbench was enabled, the hook was executed, and the validation function added to $form['#validate'], but it was no longer executed.

- I removed all workbench dependencies and settings from features.
- I disabled the workbench + moderation module.
- I enabled the workbench + moderation module.

everything started working again.

This means we cannot feature any workbench settings.

sgdev’s picture

I just ran into this same issue. Had some Workbench Moderation settings enabled through a feature, and unable to append a $form['#validate'][] through a hook_form_alter for a content type.

Also tried the exact same approach as @eMuse_be ... I used an array_unshift function to put the custom #validate at the front of the array, but still no results.

Once I disabled the Workbench settings feature, I tested again to see if the validation would work. It did not. I follow the steps that @eMuse_be documented of disabling Workbench and Workbench Moderation, then re-enabling both of them, and the validation started to work again.

I'm using Workbench 7.x-1.2 and Workbench Moderation 7.x-1.4. Also use Workbench Access 7.x-1.2.

andreyjan’s picture

As a workaround you can add validate callback to form actions:
$form['actions']['submit']['#validate'][] = 'your_module_node_form_validate';

laserlight’s picture

@andreyjan, That worked for me. It's ironic that I had to do that, to point to my hook_node_validate().