function finder_optionwidgets_finder_form_state_alter in Finder 7
Same name and namespace in other branches
- 6 modules/finder_optionwidgets/finder_optionwidgets.module \finder_optionwidgets_finder_form_state_alter()
Implements hook_finder_form_state_alter().
See also
hook_finder_form_state_alter()
File
- modules/
finder_optionwidgets/ finder_optionwidgets.module, line 231 - The finder optionwidgets module.
Code
function finder_optionwidgets_finder_form_state_alter(&$form_state, $finder_id) {
$finder =& $form_state['storage']['finder'];
foreach ($finder->elements as $key => $element) {
if (($element->element == 'buttons' || $element->element == 'select') && isset($element->settings['form']['multiple']) && $element->settings['form']['multiple']) {
// remove values in the array that are empty or 0
foreach ($form_state['values'][$element->finder_element_id] as $k => $v) {
if (!$v) {
unset($form_state['values'][$element->finder_element_id][$k]);
}
}
// append an 'empty string' choice if we just wiped the whole array and we need a value for the url args
if (!$finder->settings['advanced']['hide_args'] && empty($form_state['values'][$element->finder_element_id])) {
$form_state['values'][$element->finder_element_id][] = '';
}
}
}
}