function taxonomy_manager_tree_validate in Taxonomy Manager 6
Same name and namespace in other branches
- 5 taxonomy_manager.module \taxonomy_manager_tree_validate()
- 6.2 taxonomy_manager.module \taxonomy_manager_tree_validate()
- 7 taxonomy_manager.module \taxonomy_manager_tree_validate()
validates submitted form values checks if selected terms really belong to initial voc, if not --> form_set_error
if all is valid, selected values get added to 'selected_terms' for easy use in submit
Parameters
$form:
1 string reference to 'taxonomy_manager_tree_validate'
- taxonomy_manager_tree_process_elements in ./
taxonomy_manager.module - Processes the tree form element
File
- ./
taxonomy_manager.module, line 761 - Taxonomy Manager
Code
function taxonomy_manager_tree_validate($form, &$form_state) {
$selected = array();
if ($form['#multiple']) {
$selected = _taxonomy_manager_tree_get_selected_terms($form['#value']);
}
else {
if (is_numeric($form['#value'])) {
$selected[$form['#value']] = $form['#value'];
}
}
$vid = $form['#vid'];
foreach ($selected as $tid) {
if (!_taxonomy_manager_tree_term_valid($tid, $vid)) {
form_set_error('', t('An illegal choice has been detected. Please contact the site administrator.'));
}
}
form_set_value($form, array(
'selected_terms' => $selected,
), $form_state);
}