code_junkie

Drupal Views2 Exposed Form how to change

Nov 13th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. function views_exposed_form(&$form_state) {
  2. // Make sure that we validate because this form might be submitted
  3. // multiple times per page.
  4. $form_state['must_validate'] = TRUE;
  5. $view = &$form_state['view'];
  6. $display = &$form_state['display'];
  7. $form_state['input'] = $view->get_exposed_input();
  8. // Let form plugins know this is for exposed widgets.
  9. $form_state['exposed'] = TRUE;
  10. $form['#info'] = array();
  11. if (!variable_get('clean_url', FALSE)) {
  12. $form['q'] = array(
  13. '#type' => 'hidden',
  14. '#value' => $view->get_url(),
  15. );
  16. }
  17. // Go through each filter and let it generate its info.
  18. foreach ($view->filter as $id => $filter) {
  19. $view->filter[$id]->exposed_form($form, $form_state);
  20. if ($info = $view->filter[$id]->exposed_info()) {
  21. $form['#info']['filter-' . $id] = $info;
  22. }
  23. }
  24.  
  25. // I CHANGED The VALUE OF THIS SUBMIT BUTTON TO GO
  26.  
  27.  
  28. $form['submit'] = array(
  29. '#name' => '', // prevent from showing up in $_GET.
  30. '#type' => 'submit',
  31. '#value' => t('go'),
  32. );
  33. $form['#action'] = url($view->get_url());
  34. $form['#theme'] = views_theme_functions('views_exposed_form', $view, $display);
  35. $form['#id'] = views_css_safe('views_exposed_form-' . check_plain($view->name) . '-' . check_plain($display->id));
  36. // $form['#attributes']['class'] = array('views-exposed-form');
  37. // If using AJAX, we need the form plugin.
  38. if ($view->use_ajax) {
  39. drupal_add_js('misc/jquery.form.js');
  40. }
  41. views_add_js('dependent');
  42. return $form;
  43. }
  44.  
  45. function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
  46.  
  47. // only alter the jobs search exposed filter form
  48. if ($vars['form']['#id'] == 'views-exposed-form-jobs-search-page-1') {
  49.  
  50. // Change the text on the submit button
  51. $vars['form']['submit']['#value'] = t('Search');
  52.  
  53. // Rebuild the rendered version (submit button, rest remains unchanged)
  54. unset($vars['form']['submit']['#printed']);
  55. $vars['button'] = drupal_render($vars['form']['submit']);
  56. }
  57. }
  58.  
  59. views-exposed-form--TITLE--DISPLAY.tpl.php
  60. views-exposed-form--TITLE.tpl.php
Add Comment
Please, Sign In to add comment