function hs_subscriptions_taxonomy_validate in Hierarchical Select 5.3
Validate callback; per-user taxonomy subscriptions form.
File
- modules/
hs_subscriptions_taxonomy.module, line 93 - Makes the Taxonomy Subscriptions module use Hierarchical Select form items at user/<uid>/subscriptions/taxa.
Code
function hs_subscriptions_taxonomy_validate($form_id, $form_values, $form) {
if ($form_id == 'subscriptions_taxonomy_taxa_form') {
foreach ($form_values as $vid => $element) {
if (is_numeric($vid)) {
// Collect the tids of the selected terms.
$selected_tids = array();
foreach ($form_values[$vid]['select'] as $tid) {
$selected_tids[] = $tid;
}
// Iterate over all checkboxes.
// - When it's in the set of selected tids, then set it to 1.
// - When it's *not* in the set of selected tids, and its current value
// is 1, then set it to 0.
foreach ($form_values[$vid]['checkboxes'] as $tid => $array) {
if (!in_array($tid, $selected_tids) && $form_values[$vid]['checkboxes'][$tid][-1] == 1) {
form_set_value($form[$vid]['checkboxes'][$tid][-1], 0);
}
else {
if (in_array($tid, $selected_tids)) {
form_set_value($form[$vid]['checkboxes'][$tid][-1], 1);
}
}
}
}
}
}
}