[html-formfu] Bug in get_element: fails to work when auto_fieldset
is on
Matija Grabnar
matija at serverflow.com
Sun Oct 5 15:44:36 BST 2008
Given a form definition like this:
indicator: submit
auto_fieldset: 1
default_model: DBIC
model: DBIC
auto_label: %n
elements:
- type: Text
name: name
- type: Checkbox
name: check1
default_empty_value: 1
label: Check here for 1
- type: Checkbox
name: check2
default_empty_value: 1
label: Check here for 2
- type: Checkbox
name: check3
default_empty_value: 1
label: Check here for 4
- type: Select
name: c
empty_first: 1
constraints:
- SingleValue
A statement like my $s = $form->get_element({type=>'Select'}); will
return nothing.
However, if I remove the auto_fieldset above, the return will be correct.
My research indicates that the bug is in the _get_elements routine,
around line 50.
If auto_fieldset is on, then $elements is an array with ONE element (the
fieldset), which
contains a hash, which contains the array of more elements (the input
field, the checkboxes,
and the select). The grep only operates on the outermost array,
therefore it fails
to produce the correct result.
When auto_fieldset is not on, the $elements contains the fields
directly, without the fieldset, and
the result is correct.
I think some kind of a recursive descent into the fieldsets will have to
be implemented...
More information about the HTML-FormFu
mailing list