Drupal 7 - Attempting to add custom validation to all node edit forms -


i want add custom validation node edit forms. specifically, make image field alt , title attributes required. haven't gotten piece yet. far, have following code, reason validation helper function never called:

<?php  /*  * implements hook_form_alter()  */ function image_a11y_form_alter($form, &$form_state, &$form_id) {    // 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 found online , double checked drupal.org api doc. don't know i'm doing wrong.

you doing fine, need reference $form var on hook_form_alter()

hook_form_alter(&$form, &$form_state, $form_id) 

and never forget clear cache before dive in check. :)


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -