Skip to content

Instantly share code, notes, and snippets.

@victor-shelepen
Created February 10, 2017 11:30
Show Gist options
  • Save victor-shelepen/786746874572bc80e650645e86a6ba32 to your computer and use it in GitHub Desktop.
Save victor-shelepen/786746874572bc80e650645e86a6ba32 to your computer and use it in GitHub Desktop.
Implements the filter form that redirects to the page with parametes. Empty parameters are emmited.
/**
* Implements FORM_ID_submit.
*/
function custom_user_auto_ecole_mes_examens_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == t('Search')) {
$query = array_intersect_key(
$form_state['values']['filters'],
array_flip(
array_filter(
array_keys($form_state['values']['filters']),
function ($var) use ($form_state) {
return !empty($form_state['values']['filters'][$var]);
}
)
)
);
$form_state['redirect'] = array(
current_path(),
array('query' => array('filters' => $query))
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment