You are here

function finder_optionwidgets_finder_form_state_alter in Finder 6

Same name and namespace in other branches
  1. 7 modules/finder_optionwidgets/finder_optionwidgets.module \finder_optionwidgets_finder_form_state_alter()

Implementation of hook_finder_form_state_alter().

See also

hook_finder_form_state_alter()

File

modules/finder_optionwidgets/finder_optionwidgets.module, line 233
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') && $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][] = '';
      }
    }
  }
}