(Tips) Drupal 6 - Multiple instances of the same form on one page
Tutorial : Drupal 6 - Multiple instances of the same form on one page
There's an excellent article over on gtrlabs: Drupal 5: How to process multiple instances of the same form on the same page that describes in detail how to have multiple copies of the same form on the same page. There are some subtle differences to use this technique in Drupal 6, which I'll explain below.
The idea of this technique is simple, drupal forms are identified by their 'form_id' and these ids must be unique on a page, so if you want the same form to appear more than once, you need to change the 'form_id' somehow. We do this by appending a number to our 'form_id':
function example_view($things = array()) {
for ($i=0; $i < count($things); $i++) {
$output = drupal_get_form("example_thing_form_" . $i, $things[$i]);
}
return $output;
}
Now drupal will look for form building functions: example_thing_form_1, example_thing_form_2, etc.
Courtesy : Computerminds.co.uk
- guru's blog
- Login to post comments
![Drupal-6-Book-[Building Powerful and Robust Websites with Drupal 6].jpg](http://www.drupalranch.com/images/Drupal-6-Book-[Building%20Powerful%20and%20Robust%20Websites%20with%20Drupal%206].jpg)