I'm trying to create a Views Style plugin for the Views module in Drupal. The aim on the style plugin is to render the view as a drop down (i.e. SELECT) box.
I can't for the life of me find any decent or complete documentation on how to do this. I've looked at the source code of other Views Style plugins but that does not help.
Does anyone know how it's done or know any decent documentation, guides or tutorials on the subject?
Not sure a style element is quite what you're looking for: even if you could get the form element to render as proper HTML, the security on the forms API is going to be be hostile to any values submitted from that element.
(Form elements in Drupal have a dual life: they exist as HTML s, but also in the form_state cache. So, any form element that isn't explicitly rendered by the forms API will be discarded when the form is submitted.)
A better solution, if you're looking for views-driven form elements, would be to build the form using the normal form API and have views populate the #options
array of the element.
The function _nodereference_potential_references_views
from the nodereference
CCK add-on has a similar feature, and would probably be a good place to start. (It uses CCK hooks so you can't copy-paste directly in this case, but it should give you a pretty good sense of what you need to do)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With