sub test : Local Form { my ( $self, $c, $id ) = @_; if($c->form->validate && $c->form->submitted) { my $person = $c->accept_form({ class => 'EBusinessSphere::Persons', id => $id, }); $c->stash->{person}=$person; } else { # $id=0 unless defined $id; my $person = $c->model('EBusinessSphere::Persons')->find_or_create({id=>$id}); $c->create_form({columns=>[qw/fname lname note/],action => '/test' }); } $c->stash->{template}='index.tt2'; }