Working with multiple forms using jQuery UI Tabs

miftikhan76 - June 27, 2009 - 09:57

Hi,

I am using jQuery UI tabs for one of my module with two tabs. In tab 1 I have form of one content type A. In tab 2 I have form of 2nd content type B, which is rendered using jQuery ajax.

The problem is that I am unable to submit form of content type B, as the page have only one form tag for content type A wrapping the whole page content rather with in its own tab. Because of that, I am always submitted to content type A.

How can I have two separate forms for both content types in each tab?

Thanks and regards,
Iftikhan.

Found the solutions!

miftikhan76 - July 13, 2009 - 10:36

I was using a tpl file with drupal_render($formA) with in UI tabs.

But when I theme the form within content type A module and use drupal_render($formA) there, it worked. I used following code:

<?php
function theme_contenttypeA_form($node,$type)
{
   
//return _phptemplate_callback('contenttypeA-edit', array('form' => $form));//problem implementation

   
$output='<div id="tabs">';
   
$output.='<ul>';
   
$output.='<li><a href="#tabs-1">Tab A</a></li>';
   
$output.='<li><a class="tabs-2-link" href="#tabs-2">Tab2</a></li>';//will be populated throgh jquery ajax
   
$output.='</ul>';
   
$output.='<div id="tabs-1">';
   
$output.= drupal_get_form('contenttypeA_node_form', $node);
   
$output.='</div>';
   
$output.='<div id="tabs-2"></div>';
    return
$output;
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.