[html-formfu] Re: probably bug in nested forms
Mario Minati
mario.minati at googlemail.com
Sat Nov 3 23:13:30 GMT 2007
replied to myself :roll:
---------- Forwarded Message ----------
Subject: Re: probably bug in nested forms
Date: Sonntag 04 November 2007
From: Mario Minati <mario.minati at googlemail.com>
To: Mario Minati <mario.minati at googlemail.com>
On Saturday 03 November 2007 23:52:06 you wrote:
> 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
Changing nested_name in Block to be created by mk_accessors instead of
mk_inherited_accessors solves the problem. The tests are running smoothly and
my warn statements show what I expected.
I uploaded a fixed version, but must addmit that I was to lazy to write a test
case for this bug.
Greets,
Mario
-------------------------------------------------------
More information about the HTML-FormFu
mailing list