function trim_form_alter in Trim 7
Same name and namespace in other branches
- 8 trim.module \trim_form_alter()
Implements hook_form_alter().
File
- ./
trim.module, line 6
Code
function trim_form_alter(&$form, &$form_state, $form_id) {
// Ensure that there is an array here.
if (!isset($form['#validate'])) {
$form['#validate'] = array();
}
// And if someone has set it as a string, fix that issue. You'd be surprised.
if (!is_array($form['#validate'])) {
$form['#validate'] = array(
$form['#validate'],
);
}
// Now add a new function to the list, but ensure that it is called first.
array_unshift($form['#validate'], 'trim_form_values');
}