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