[development] AHAH with fieldsets not rebuilding correctly

Jeff Hartman lists at jeffhartman.com
Sat Feb 19 16:09:06 UTC 2011

On Feb 19, 2011, at 9:21 AM, Andrew Berry wrote:

> On 2011-02-19, at 10:00 AM, Jeff Hartman wrote:
>> Getting ahah to work in general is not the problem. I have it working on one form as I mentioned. The problem form has the values within a fieldset and the fields with updated data are generating new fields instead of replacing the existing values. It may not be the fieldset that is the problem, but I'm supposing it is because that's the main difference between the forms.
> Are you missing '#tree' on the fieldset element? Or, consider putting it at the top level of your form.
> --Andrew

Yes, this is on the right track. My original form does have #tree included. I have to redefine all the fieldsets *within* the ahah function and that seems to get closer. The names of the fields are still slightly different.

Field name before ahah:
<input name="details[guests][1][address][state]" ...

Field name after ahah:
<input name="guests[1][address][state]" ...

It's like I'm missing 1 level of depth in the form. Details is not in the $form array as I'm creating the form so I assume that is added when Drupal creates the form. I am not sure how I generate that extra level. It doesn't work if create an empty $form = array('#tree' => true); or $form['details'] = array('#type' => fieldset, '#tree' => true), in the ahah function.


More information about the development mailing list