Change exposed filter with 'start with' operator text field into dropdown A-Z filter like glossary

Public

</> CopyGet raw version
php
  1. function YOUR_MODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  2. if ($form_id == "views_exposed_form" && $form['#id'] == 'YOUR_EXPOSED_FORM_ID' ){
  3. $options = array("" => "A-Z",);
  4. foreach (range('a', 'z') as $letter) {
  5. $letters[$letter] = strtoupper($letter);
  6. }
  7. $options += $letters;
  8. $form['YOUE_EXPOSED_FIELD'] = array(
  9. '#type' => 'select',
  10. '#theme' => 'select',
  11. '#size' => 1,
  12. '#multiple' => FALSE,
  13. '#default_value' => '',
  14. '#options' => $options,
  15. );
  16. }
  17. }
  18. }