On 02/03/07, Will Hawes <[EMAIL PROTECTED]> wrote:
This was observed using HTML::Widget version 1.10:$form = HTML::Widget->new(); $form->element('Hidden','hidden1'); $form->element('Textfield')->name('textfield1'); $result = $form->process( $params ); print scalar $result->elements; # prints "2" ($result->elements contains 'hidden1' and 'textfield1') $form = HTML::Widget->new(); $form->element('Hidden','hidden1'); $fieldset = $form->element( 'Fieldset', 'fieldset1' ); $fieldset->element('Textfield')->name('textfield1'); $result = $form->process( $params ); print scalar $result->elements; # prints "1" ($result->elements contains only 'hidden1') It appears that if a HTML::Widget::Element::Fieldset is added to a widget after any other element (other than another Fieldset), it is not returned by $result->elements. Adding all non-Fieldset elements to a Fieldset and adding that to the main widget, so only Fieldsets are added to the main widget, seems to be an effective workaround.
HTML::Widget's handling of fieldsets is somewhat broken; if you search the mailing list archives, you'll find plenty of discussion about it last year. This is one of the reasons I started developing HTML::FormFu instead.
Is this expected behaviour? If best practice is to wrap all elements in Fieldsets, I'd have expected a warning/error of some sort when trying to do it differently.
According to the xhtml spec, forms can only contain block-level elements, which means that inputs must be within a fieldset, or other block-level item, such as a p or div. Unfortunately, backwards compatability required that it wasn't mandatory to add a fieldset first. Carl _______________________________________________ Html-widget mailing list [email protected] http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
