I have nearly the same problem than this : Multiple forms on single page?
But the answer is for an inclusion on a page template and I want to do the same on a node template where I can't use any incremental ID loop. I'm using Drupal 7.
I have nearly the same problem than this : Multiple forms on single page?
But the answer is for an inclusion on a page template and I want to do the same on a node template where I can't use any incremental ID loop. I'm using Drupal 7.
In either Display Suite or a node template
just call the forms using drupal_get_form
each form will given a unique build_id
and there should be no problem displaying any number of forms on the page.
hook_forms
in this answer https://drupal.stackexchange.com/a/6230/3279 has nothing to do with your question. You don't need to worry about incremental form IDs or anything.
Here is an example of how to use a preprocess function for a Node (type): http://purencool.com/drupal-7-preprocess-tutorial-adding-variable-to-template this uses this Drupal API function https://api.drupal.org/api/drupal/modules!node!node.module/function/template_preprocess_node/7
Your code would look something like (this is example code not guarenteed to work):
function MYMODULE_preprocess_node(&$vars) {
if ($vars['node']->type == 'MY_NODE_TYPE') {
// link to webform paths.
$vars['custom_form_links'] = implode(' ', array(l('Please Fillout Form 1', 'some/path/to/webform'), l('Please Fillout Form 2', 'some/path/to/webform2')));
// Or just embed the forms.
$form1 = drupal_render(drupal_get_form('myform1'));
$form2 = drupal_render(drupal_get_form('myform2'));
$vars['custom_forms_embed'] = $form1 . $form2; // You may want additional HTML wrappers, figure it out.
}
}
Then in your themes template files for like node--YOURCONTENTTYPE.tpl.php
you echo these new variables.
Display Suite makes all this a ton easier with Code Fields
, or custom fields, and dynamic view_modes
so you don't need to touch template files either ...
None of this code is guarenteed to run -- it's just a rough example.
I think you can get your form on template if you know their ids.
$form1 = drupal_get_form('form1_id');
$form2 = drupal_get_form('form2_id');
And then render by drupal_render()
drupal_render($form1);
drupal_render($form2);
Use Panels module. You can embed any number of webforms in a single page using panels module. Create a custom page and add existing nodes as content