Archive for October, 2014

Drupal webform/custom form render multiple times on same page

I needed to place the same form multiple times on a drupal page but still be unique so that FAPI would know which one was being submitted.

To do that, first thing we need to render the same form in our function with non-existing form_id as follow:-


$form = drupal_get_form(‘webform_client_form_’ . $webform_nid . ‘_’ . $nid, $node);

* it means ‘webform_client_form_’ . $webform_nid . ‘_’ . $nid  form_id does not exists in the Drupal site. 


Then we need to define hook_forms function in module.

function hook_forms($form_id, $args) {
$forms = array();
if (strncmp($form_id, ‘webform_client_form_’, 20) === 0) {
$forms[‘webform_client_form_’ . $args[0]->nid] = array(‘callback’ => ‘webform_client_form_’ . $args[0]->nid);
return $forms;

This is an example for same webform rendering multiple times in same page. It will work for custom form as well. It will also do the trick to track which form is submitted.  It will do validate only the form where button is clicked.



Leave a comment