views:

43

answers:

1

I'm making use of the Favorites module, in order to allow my users to favorite nodes they like.

Currently, I know that there is a block available for listing out the favorites, along with the 'Add to favorites' button at the top of this list.

What I'd like to do is generate the form which includes the button, and include it within each node that I generate. I'd gotten it hacked up and quickly working by copying the generated form and placing it in my views-view--fields-.tpl.php template, however I believe that doing it this way goes against the thought behind Drupal, and probably introduces security issues with the form_id and form_token being hand-written.

I've attempted to call the get_form function, and have passed it the form_id that I found in the generated form code, however I can't get Drupal to recognize it. From some Googling I've noticed that generating module forms programmatically may require a hook, but I haven't been able to find any good examples of this.

What is the best way to go about creating this form?

+1  A: 

if you have a block already, can you put the block in your content region and only show it on certain pages?

I've never used Favorites, but from your description, I would probably use the flag module instead. It uses ajax, and it's really easy to include an add/un-flag link in the node view.

For a programmatic direction, I would have looked at drupal_get_form, as well. Where are you injecting that code?

sprugman
i went with your suggestion and played around with the flag module...it seems to be a lot more powerful and suits my purposes...thanks!!! regarding your question, i was injecting it in my view-view--fields-<view_name>.tpl.php
espais

related questions