I want to add custom validation to all node edit forms. Specifically, will make any image field alt and title attributes required. But I haven't even gotten to that piece yet. So far, I have the following code, but for some reason my validation helper function is never called:
<?php
/*
* Implements hook_form_alter()
*/
function image_a11y_form_alter($form, &$form_state, &$form_id) {
// Do this for ALL node edit forms (not specific form ID)
if (isset($form['#node_edit_form']) && $form['#node_edit_form'] == TRUE) {
$form['#validate'][] = 'custom_validate';
}
}
function custom_validate($form, &$form_state){
// Custom validation here
}
I've followed several examples I found online and double checked the Drupal.org API doc. I don't know what I'm doing wrong.