[development] AHAH with fieldsets not rebuilding correctly

Randy Fay randy at randyfay.com
Sat Feb 19 06:42:01 UTC 2011

The Examples project has a complete dependent dropdown example in the AHAH
Example.  If I were you I would copy it and adapt it.


On Fri, Feb 18, 2011 at 11:05 PM, Jeff Hartman <lists at jeffhartman.com>wrote:

> Hey list,
> I've got a couple forms that use AHAH functions to generate a drop down of
> states/provinces based on the user's selection in a country drop down menu.
> I'm using a very similar method as is found here:
>        http://drupal.org/node/331941
> One form works fine with fields as $form['country'] and $form['state']. The
> other form uses fieldsets and those fields get renamed and lose their
> hierarchy after the form is rebuilt.
> So for example, the following fields start out like:
>        $form['guest'][1]['country']
>        $form['guest'][1]['state']
>        $form['guest'][1]['zip']
> But after the form is rebuilt with form_builder and drupal_render using:
>        $output = drupal_render($form['guest'][1]['state']);
>        $output .= drupal_render($form['guest'][1]['zipcode']);
>        // Render form output as JSON
>        print drupal_json(array('data' => $output, 'status' => true));
> The rebuilt fields are logically placed outside of the fieldset and end up
> as:
>        $form_state['guest'][1]['country']
>        $form_state['state']
>        $form_state['zip']
> Thoughts on what might cause that? Thanks for any direction. I've struggled
> with this for hours!
> Jeff

Randy Fay
Drupal Module and Site Development
randy at randyfay.com
+1  970.462.7450
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110218/e74e7548/attachment.html 

More information about the development mailing list