[Html-widget] Fieldset not returned by $result->elements if
non-Fieldset added first
Will Hawes
wdhawes at gmail.com
Fri Mar 2 11:59:21 GMT 2007
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.
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.
Thanks, Will
More information about the Html-widget
mailing list