[Catalyst] CDBI => Web (opposite of Class::DBI::FromForm)
Roland Moriz
roland at moriz.de
Mon Nov 7 02:47:07 CET 2005
Hi Everybody,
I like it very much to use ::FormValidator, ::FillInForm and ::FromForm
to create html forms, validate the input and put the valid data into the
DBI then.
But I'm missing a feature - maybe someone already has created it?
When I display a page where the user should be able to edit data I have
to get it out of the Model/CDBI and then fill the corresponding
form-fields within the template manually.
I think this is not DRY and can be done by ::FillInForm object filled
with a retrieved CDBI object - just the inverse way that
Class::DBI::FromForm goes from a ::FormValidator object...
Should be possible, shouldn't it?
Do we have such a functionality already available?
A small hack for text-fields seems to be:
sub load_form : Path('lalala/view') {
my ($self, $c) = @_;
$c->stash->{template} = 'user/register.tt';
my $user = App::Model::CDBI::User->search( id => "114" )->first;
%{$c->stash->{fnf}} = map { $_ => $user->$_ } $user->columns();
}
sub end {
$c->forward('App::View::TT') unless $c->response->body;
if (defined($c->stash->{fnf})) {
$c->fillform($c->stash->{fnf});
}
}
But what about the other <input> and types?
Dropdowns, checkboxes, radioboxes?
Mit freundlichen Gruessen,
with best regards,
Roland Moriz
More information about the Catalyst
mailing list