[html-formfu] Re: probably bug in nested forms

Mario Minati mario.minati at googlemail.com
Sat Nov 3 22:52:06 GMT 2007


On Saturday 03 November 2007 23:18:57 you wrote:
> Hi,
>
> while reworking the DBIx::Class::HTML::FormFu::fill_formfu_values I found
> misformed nested_names:
>
> YAML config of elements (constraints removed for readability):
> ---
> elements:
>
>   - type: Fieldset
>     legend_loc: Description
>     nested_name: description2
>     elements:
>
>       - type: Text
>         name: description
>         label_loc: Label
>
>       - type: Multi
>         label_loc: Use for
>         container_attrs:
>           class: vertical
>         elements:
>
>           - type: Checkbox
>             name: use_for_shipping
>             label_loc: Shipping
>
>           - type: Checkbox
>             name: use_for_routing
>             label_loc: Routing
>
>           - type: Checkbox
>             name: use_for_billing
>             label_loc: billing
>
>
> I dumped the nested_names in DBIx::Class::HTML::FormFu::fill_formfu_values
> like this:
>
> ...
>     for my $field (@$fields) {
>         my $field_name = $field->name;
>         my $field_nested_name = $field->nested_name;
> warn $field_nested_name;
>         next unless defined $field_name;
> ...
>
> And here is the output:
>
> description2[description]
> at
> /home/mario/Desktop/dev/projects/formfu/svn/trunk/DBIx-Class-HTML-FormFu/li
>b/DBIx/Class/HTML/FormFu.pm line 37.
> description2[description2][use_for_shipping]
> at
> /home/mario/Desktop/dev/projects/formfu/svn/trunk/DBIx-Class-HTML-FormFu/li
>b/DBIx/Class/HTML/FormFu.pm line 37.
> description2[description2][use_for_routing]
> at
> /home/mario/Desktop/dev/projects/formfu/svn/trunk/DBIx-Class-HTML-FormFu/li
>b/DBIx/Class/HTML/FormFu.pm line 37.
> description2[description2][use_for_billing]
> at
> /home/mario/Desktop/dev/projects/formfu/svn/trunk/DBIx-Class-HTML-FormFu/li
>b/DBIx/Class/HTML/FormFu.pm line 37.
>
> So the nested_name 'description2' gets repeated two times, probably because
> of the Multi element in the config.
>
> I'll go hunting ;-)
>
> Greets,
> Mario

After finding out why a warn caused Perl to segfault I found the reason for 
this behaviour:

Multi is inherited from Block.
Block defines nested_name as inherited accessor.
So if Multi does not have a nested_name tag, but the surrounding Fieldset, 
then Multi also gets the nested_name from it's parent and the 
_Field:nested_names function get's it once more.

Greets,
Mario



More information about the HTML-FormFu mailing list