Customizing Exposed Field

Events happening in the community are now at Drupal community events on www.drupal.org.
qjensen's picture

I am very new to working with the Views API and I can't seem to figure out how to customize the display of an exposed field in a view.

I have a CCK field that I have exposed, but instead of leaving it as a bare text field I would like to replace it with a select that includes the items actually in the db.

For example, I have a field for Fruit. That could be any kind of fruit and not every fruit is in in the db, so I want to create a select list that would allow the user to select from a list of fruit that has been entered in the system.

Does this make sense? Is it possible with the Views API?

Thanks for pointing me in the right direction.

Comments

It makes sense, but...

shushu's picture

It makes sense, but unfortunately it is not an "out of the box" feature.

Try to follow these instructions.

Good Luck !

Not Even with the API?

qjensen's picture

I thought about that option, but since people will be making new entries all of the time it will be impossible to keep a list like that up to date manually.

I am not afraid of writing code to make this happen. The API doesn't give me any tools to do this?

Another direction - autocomplete

shushu's picture

Well, another solution is the autocomplete concept.
I have used it several times, but it does not give you exactly what you want - no select box...
Since you have said you are no afraid from coding, maybe you can accomplish your task by creating new autocomplete widget as described here.

The idea, as I see it, is a selectbox options filled by a view, but I couldn't find anything like that existing till now.

For data input:

scottprive's picture

For data input: http://drupal.org/project/cck_select_other

I haven't tried it, but it seems to partially match your description.
Unfortunately, it's not a search/selection widget inside Views - it's for CCK forms.
Once the data is past CCK, it looks like it's stored as normal data.

Views is mostly display of data, so by default you are not going to get this or other widgets exposed in Views. (It's worth investigating the modules that try to forms-enable Views results, such as "viewsff")

But even if this only looks like what you want, you can study it, and emulate it in a view using Views Customfield http://drupal.org/project/views_customfield
For example, you could have a custom field that injects both a list and a textfield. The customfield will need to be smart enough to parse both widgets and understand if one is blank and the other set (or if both are blank. etc) and get the input as needed. You might need a hidden/dummy field (not displayed, but which takes the true input from the customfield). At least, this is how I'd break it down for my own investigation.

I don't know for certain there isn't a Views module that already does what you ask, but I haven't seen one.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: