I would like to add some custom validation to a node form. But for some reason the validate function is skipped, the submit function does gets called.
/*
* Custom Form settings
*/
function frontpage_banners_form_promo_banner_node_form_alter(&$form, &$form_state, $form_id) {
$form['#validate'][] = 'frontpage_banners_form_promo_banner_node_form_validate';
$form['#submit'][] = 'frontpage_banners_form_promo_banner_node_form_submit';
dpm($form_id);
dpm($form);
}
function frontpage_banners_form_promo_banner_node_form_validate(&$form, &$form_state) {
drupal_set_message('error');
form_set_error('', t('Email must be valid format if entered.'));
}
function frontpage_banners_form_promo_banner_node_form_submit(&$form, &$form_state) {
drupal_set_message('submit');
}
I tried several function names but nothing seems the work.
From the $form array:
#validate (Array, 2 elements)
0 (String, 18 characters ) node_form_validate | (Callback) node_form_validate();
1 (String, 54 characters ) frontpage_banners_form_promo_banner_node_form_v... |
exit;
after yourform_set_error();
. – hampusn Sep 10 '12 at 9:19