Set values for an exposed field in a block (in Drupal)?
I've set up a view of "properties". One of the fields is "price". Now, i've exposed price in a block, so that you can search for it from the block. The problem is that when you view the block, i开发者_Python百科t shows the field as a box where you can enter a value. What I want is a dropdown, where you can select the following options:
- < 1 million
- < 2 million
- < 3 million
Anyone know how to do that?
I believe you should be able to use hook_form_alter
to change the field into a select
field.
The problem is not that you want a select box, it's the level of specialization you want out of the exposed filter. Views can't see what it is you want as options, so it doesn't given you any.
If you wanted to make this functionality configurable from within views (instead of in the CCK Field settings), you would probably want to extend the Views Filter Pack.
However, your easiest option is hook_form_alter, unless the Textfield widget supports "Allowed Values", which I doubt.
精彩评论