[html-formfu] nested_name in a Radiogroup element

Carl Franks fireartist at gmail.com
Tue Nov 20 16:22:21 GMT 2007


On 20/11/2007, Jonas Alves <jonas.alves at gmail.com> wrote:
> Hi there,
> I need to set a nested_name in a radiogroup element. It's possible to do that?
> If I do somethig like this:
> - type: Radiogroup
>   nested_name: user
>   name: gender
>    options:
>        - [ 'm', 'Male' ]
>        - [ 'f', 'Female' ]
>
> I get this error message: "cannot set nested_name at
> /Library/Perl/5.8.6/HTML/FormFu/ObjectUtil.pm line 266"
>
> Probably I need to patch Radiogroup to pass the nested_name parameter
> to the Fieldset.

I'll need to have a think about this.
At the moment, only Blocks can have nested_name() set, for Fields,
it's a readonly method which calculates the name based on the
nested_name of any parent blocks.

I think I've used these assumptions in some of my code for the new
HTML-FormFu-Model-DBIC, so I'll need to take a look at that, to see
what the consequences of allowing Radiogroup to override nested_name()
would be.

You also can't really pass anything to the Radiogroup's fieldset, as
it's not actually a fieldset object, the fieldset only exists in the
radiogroup template file.

A temporary work-around would have to be:

    ---
    elements:
      - type: Block
        tag: ~
        nested_name: user
        elements:
          - type: Radiogroup
            name: gender
            options: [ [m, Male], [f, Female] ]

Also, is it necessary to use nested_name here?
I've just realised that I've discussed this with Brian C off-list, but
haven't discussed this on the list yet...
The nested_name feature won't be pushed out to cpan until the
FormFu-Model-DBIC work is done, because I don't want anybody using
nested_name just "because it's there".

The reason for this is that FormFu-Model-DBIC will require you to
follow conventions matching field names to column names, and block's
nested_name to relationship names.
This provides the ability to fill a forms' default values from a
single row, following any depth of relationships, with a single method
call.
Likewise, you can update a dbic row, and any depth of relationships
from a submitted form, using only one method call.
I expect this functionality to be later extended to allow configuring,
so that you don't have to follow these conventions, but that's for a
later date (and probably for someone else interested in it, to code).

Carl



More information about the HTML-FormFu mailing list