开发者

Drupal views add form to add record

I have some view which lists my module table entries. What is the most elegant way to attach a form below the view to add record? Waht I am trying to do know is:

  1. I created dedicated form in my module:

    function my_module_form_add_record($form_state) {
    form fields.....
    

    }

  2. I added to the view theme file:

    $add_form = drupal_get_form('my_module_form_add_record'); print $add_form;

But I do not like this solution for at least 2 reasons:

  1. I does not work ...

2. Even if it worked - it is depended on the theme file! So if I change the theme - functionality is crashed. I would like to find more elegant solution to attach form from custom module to the view.

I know of the existence of the "Views Attach" module but it has no option of adding custom forms. I know also of the existence of the Views Embedded form (and I am usig it) but it is only useful if you want to add form开发者_如何转开发 to the every row.

Seems the must be some solution to add record from the view page! Thanks you for help.


you could use hook_views_pre_render:

This hook is called right before the render process. The query has been executed, and the pre_render() phase has already happened for handlers, so all data should be available.

Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after. Altering the content can be achieved by editing the items of $view->result.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜