[Catalyst] html::widget
Hermida, Leandro
Leandro.Hermida at fmi.ch
Wed Dec 6 21:38:48 GMT 2006
Hello,
I am no DBIx::Class expert but I think one way of doing it is first
using the primary key or a unique constraint of the table Book to
find the object you want and then update it. Something like
this:
my $book = $c->model('MyApp::Book')->find($book_pk_id);
$book->title($new_title);
$book->rating($new_rating);
$book->update;
Leandro
________________________________
From: Will Smith [mailto:willbelair at yahoo.com]
Sent: Wednesday, December 06, 2006 21:53
To: catalyst
Subject: [Catalyst] html::widget
Hi,
It's pretty neat to use html::widget to create/validate html
form. Problem is I need to create a lot of customized html forms that
could not done easily with html::widget. I want to simply do my own html
form and use a normal action to update the record.
I tried to use somehing like:
my $book = $c->model('myapp::Book')->update({
title => $title,
rating => $rating,
});
but of course, it updates the whole table, not only the wanted
record, because I do not put in the condition "where".
I used to use : update_from_form in older version of catalyst.
Could someone please show me the syntax to do the update, either
adding condition to the above method (which I think there is a simple
way), or using update_from_form
something like the old timer:
$c->for( optional => [ myapp::M::CDBI::books->columns ] );
..
myapp::M::CDBI::books->retrieve($id)->update_from_form(
$c->form);
Thank you
More information about the Catalyst
mailing list