I have created different node forms for different content types, by using this function in my template:
function mytheme_theme($existing, $type, $theme, $path) {
return array(
'type1_form' => array(
'arguments' => array('form' => NULL),
'template' => 'type1_form'
),
'type2_form' => array(
'arguments' => array('form' => NULL),
'template' => 'type2_form'
),
);
}
Now I'd like to make a validate function for one of the forms. I tried using this function in template.php:
function mytheme_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'type1_form') {
$form['#validate'][] = 'my_sample_validate_func';
}
}
function my_sample_validate_func($form, &$form_state) {
dsm($form_state);
}
But apparently the hook_form_alter isn't avaliable to the theme layer. Do I have to make a new module to accomplish this?