[html-formfu] two form in one page
hallouina-formfu at yahoo.fr
hallouina-formfu at yahoo.fr
Sun Jun 1 17:00:02 BST 2008
Hello everybody,
I try to add multiple forms in one page. I can display it with one yaml file for each form.
The problem is that nothing appends when I validate the first or the second form.
Nothing is added in my database, and I my page is display again without any error.
I try to do without FormConfig, because I have two config file, so I do like that :
sub view : Local {
my ( $self, $c, $id_person ) = @_;
#############################################################################################
#my first form to add information about the person
my $form = HTML::FormFu->new;
$form->load_config_file('root/forms/person/view.yml');
$c->stash->{form} = $form;
$form->add_valid ( person_id => $id_person ) ;
$form->action( "/person/view/$id_person#tab1");
if ($form->submitted_and_valid) {
my $contactinfo = $c->model('DB::Contactinfo')->new_result({});
$form->save_to_model($contactinfo);
$c->response->redirect($c->uri_for("/person/view/$id_person#tab1")); $c->detach;
}
#############################################################################################
#############################################################################################
#the second form to add message with the person
my $form2 = HTML::FormFu->new;
$form2->load_config_file('root/forms/person/addmsg.yml');
$c->stash->{form2} = $form2;
$form2->add_valid ( person_id => $id_person ) ;
$form2->add_valid ( datemsg => DateTime->now() ) ;
$form2->action("/person/view/$id_person#tab2");
if ($form2->submitted_and_valid) {
my $contactmsg = $c->model('DB::Contactmsg')->new_result({});
$form2->save_to_model($contactmsg);
$c->response->redirect($c->uri_for("/person/view/$id_person#tab2")); $c->detach;
}
#############################################################################################
$c->stash->{contactmsgs} = [$c->model('DB::contactmsg')->search( person_Id => $id_person ) ];
$c->stash->{contactinfos} = [$c->model('DB::contactinfo')->search( person_Id => $id_person ) ];
$c->stash->{person} = $c->model('DB::person')->find( Id => $id_person ) ;
$c->stash->{template} = 'person/view.tt2';
}
I try to add $form->process and $form2->process after $c->stash->{form2} = $form2; But I get no improvement.
Someone have an idea from what it could come from please ? Or maybe I don't do with the right way ?
Thanks for you attention,
Antoine.
__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités
http://mail.yahoo.fr Yahoo! Mail
More information about the HTML-FormFu
mailing list