Drupal Views2 Exposed Form how to change

后端 未结 5 1455
清歌不尽
清歌不尽 2021-01-15 14:56

I have a View with an exposed form . I am trying to a few things on it. Ideally I would like to have a dropdown that fires the form with no button. If that is not possible t

5条回答
  •  庸人自扰
    2021-01-15 15:14

    Or, you could use a preprocess function to alter the form even before it is build. I wanted to change the text on the button, so I did this:

    function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
    
      // only alter the jobs search exposed filter form
      if ($vars['form']['#id'] == 'views-exposed-form-jobs-search-page-1') {
    
        // Change the text on the submit button
        $vars['form']['submit']['#value'] = t('Search');
    
        // Rebuild the rendered version (submit button, rest remains unchanged)
        unset($vars['form']['submit']['#printed']);
        $vars['button'] = drupal_render($vars['form']['submit']);
      }
    }
    

提交回复
热议问题