0

Im using hook_preprocess_views_exposed_form to change the output of my views exposed search box. I am able to successfully change the text on the search button, but I am not able to change the size. I cant figure out where I am going wrong. Here is what I have:

function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
  // dsm($vars['form']);
  if ($vars['form']['#id'] == 'views-exposed-form-all-page') {
    $vars['form']['submit']['#value'] = t('Go');
    $form['text']['#size'] = '90';
    unset($vars['form']['submit']['#printed']);
    $vars['button'] = drupal_render($vars['form']['submit']);
  }
}

This is what I am stuck on:

$form['text']['#size'] = '90';
2
  • $form['text'] is it correct index? Commented Dec 15, 2012 at 7:03
  • Its $...['keys']['#size'], but I can get that to work either
    – joe
    Commented Dec 15, 2012 at 7:32

1 Answer 1

0

I think it would be better to change the form sooner than during themeing ... the best is to implement a form_alter hook, in this case

function MODULENAME_form_views_exposed_form_alter(&$form, $form_state)

you can try to dpm($form) first, to see what exactly you should change, and probably also add a condition about module id.

if you install advanced_help, this info can be found on your site at help/views/alter-exposed-filter :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.