Skip to content

Instantly share code, notes, and snippets.

@henrytran9x
Last active August 29, 2015 14:16
Show Gist options
  • Save henrytran9x/24dd5c41c8934e58f7ad to your computer and use it in GitHub Desktop.
Save henrytran9x/24dd5c41c8934e58f7ad to your computer and use it in GitHub Desktop.
Show amount of results for exposed filter Drupal 7
function mymodule_form_alter(&$form, &$form_state, $form_id) {
switch($form_id){
case 'views_exposed_form':
foreach ($form['field_marka_prochnosti_tid']['#options'] as $tid => &$value) {
$query = db_select('field_data_field_marka_prochnosti', 'f')
->condition('f.field_marka_prochnosti_tid', $tid);
$query->addExpression('COUNT(*)');
$count = $query->execute()->fetchField();
$value = $value . ' (' . $count . ')';
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment