开发者

Overriding an input of the Exposed Views form to render a range of values

In the Exposed Views form (Drupal 6, Views 2), I'd like to overwrite an input text so it render the option to choose from a r开发者_开发技巧ange of values, something similar to this:

Overriding an input of the Exposed Views form to render a range of values

Or just a simple one: two text inputs with from and to labels (min, max, whatever, like a price range).

I am comfortable both with editing templates (views-exposed-form.tpl.php in this case) and overwritting the form output:

function mymodule_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'views_exposed_form') {
        $form['submit']['#value'] = t('Filter');
    }
}

How can I change the defaul text input to one as described?


I am doing something similar as a template function. You can remove the rendered output and render your own as a theming function.

function THEME_preprocess_views_exposed_form(&$vars, $hook) {
  switch($vars['form']['#id']){
    case 'views-exposed-form-VIEW_NAME-page-1':
      $vars['widgets']['filter-YOUR_FIELD']->widget = YOUR_CODE_HERE;
  }
}

Be sure to use dpm() from the Devel module to figure the identifiers you need to use because might be slightly different in the theme layer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜