开发者

How to create a Views style plugin for Drupal?

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 documenta开发者_运维问答tion 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)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜