[Catalyst] CRUD Question. How to update a record.

Hans Ophüls hop at shoppilot.de
Mon Feb 19 00:20:32 GMT 2007


Hello,

I have just started with catalyst.
I have worked through the tutorial
and every thing works fine yet.

But I have a problem with implementing an
update function.
It schould select a record from the database
and insert the data into a widget.

sub hw_update : Local {
    my ($self, $c, $id) = @_;

    # Search for the product 
    c->model('MyAppDB::Product')->search({id => $id});

    # Create the widget and set the action for the form
    my $w = $self->make_product_widget($c);
    $w->action($c->uri_for('hw_create_do'));

....

sub make_product_widget {
    my ($self, $c) = @_;

    # Create an HTML::Widget to build the form
    my $w = $c->widget('product_form')->method('post');

    # Create the form fields
    my $e = $w->element('Textfield', 'itemid'  )->label('ItemId')->size(30);
    $e->value('4711');

Just where there is '4711' should be the value from the column 'itemid'.
I have tried various expression with
$c->model('MyAppDB::Product')...
but I have not found the right way.

Can anybody help please.

Hans




More information about the Catalyst mailing list