It's not working for me using the below code:
$form['field1'] = array(
'#title' => t('Field1'),
'#size' => 24,
'#type' => 'textfield',
'#default_value' =>$field ,
'#required' => TRUE,
'#element_validate' => array('function_name'),
);
if(($form_state['values']['field1']=='' ){
form_set_error('field1', t('one field is required'));
}
getting the error message in red at the top but my text box is not getting highlighted with red border.
I have used this text box in hook_form in a module, but i have called this form in theme using
print render(drupal_get_form('hook_form'));
I guess the error message is not getting highlighted since am calling this in a theme.
This is getting worked when i call my form in a module but i want the form to be called from a template. In this case my error message is not getting highlighted with red border over the text box.