--
You received this message because you are subscribed to the Google Groups "formhandler" group.
To post to this group, send email to formh...@googlegroups.com.
To unsubscribe from this group, send email to formhandler...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/formhandler?hl=en.
Gerda
On 2/4/12 4:47 PM, Matthias Dietrich wrote:
Is there some reason you don't want to create multiple instances of the form?
For example: https://github.com/gshank/formhandler-example/blob/master/lib/MyApp/Controller/Bootstrap.pm
The 'basic' action is creating three instances of MyApp::Form::Basic. Unless there's a lot of overhead in constructing your form, I wouldn't think it would be worth it to clone them.
If you want the options to only load once in that example, you could get them outside FormHandler and pass them into the form.
You don't have to separate out the params in that example, because of the 'html_prefix' setting. That adds a prefix to the field names, so each form will only process its own params.
You could take the options that are built on the first copy and pass them into the additional copies:
my $form1 = MyApp::Form->new;
my $options = $form1->field('my_field')->options;
my $form2 = MyApp::Form->new( field_list => [ '+my_field' => { options => $options} ] );
my $form3 = MyApp::Form->new( field-list => [ '+my_field' => { options => $options} ] );