[html-formfu] DBIC-FormFu extension

Mario Minati mario.minati at googlemail.com
Wed Sep 19 11:05:46 GMT 2007


On Wednesday 19 September 2007 11:02:47 Carl Franks wrote:
> On 18/09/2007, Mario Minati <mario.minati at googlemail.com> wrote:
> > If you have the following form fields:
> >     private_street
> >     private_city
> >     private_email
> >     office_street
> >     office_city
> >     office_email
> >
> > You most likely would like to save both datasets in same table:
> >     my $private = $user->new_related( 'data', { type => 'private' } );
> >     $private->populate_from_formfu( $form, { prefix_col => 'private_' }
> > ); my $office = $user->new_related( 'data', { type => 'office' } );
> > $office->populate_from_formfu( $form, { prefix_col => 'office_' } );
>
> I think a more elegant solution would be by adding support for
> 'nested' params, e.g.
>
> with the following input:
>     "private.street" => x
>     "private.city" => y
>     "private.email" => z
>
> $form->param('private') would return a hashref:
> {
>     street => x,
>     city => y,
>     email => z,
> }

This idea is more general and useful. 

> (or use the alternative syntax, "private[street]", "private[city]", etc.)

Can we get HTML problems with parameter names including '.' or '[]' (I 
favour '.' as it would allow chaining.)

> Then do something like:
>
>     $relationship->populate_from_formfu(
>         $form,
>         { param => 'private' } );
>
> Also, it's maybe not immediately helpful in this example, but I'd like
> to break out the logic from Element/Dojo/Repeatable.pm into a core
> Element/Repeatable.pm element.
> This could help with some relationships, as it would provide automatic
> handling of multiple fields by adding an increasing numerical suffix
> to the fieldname.

Would you do a more deeply change in FormFu, like adding an additional 
parameter to fieldset like
- fieldset
    my_parameters_belong_to: private
    elements:
      - type: Text
        name: just_name

which will lead to 'private.just_name' in HTML code.

Or just use 'private.just_name' as name?

Greets,
Mario



More information about the HTML-FormFu mailing list