[html-formfu] DBIC-FormFu extension
    Carl Franks 
    fireartist at gmail.com
       
    Wed Sep 19 10:02:47 GMT 2007
    
    
  
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,
}
(or use the alternative syntax, "private[street]", "private[city]", etc.)
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.
Carl
    
    
More information about the HTML-FormFu
mailing list