<div>you can use this to add value to a text field:</div> <div>my $e = $w->element('Textfield', 'itemid' )->label('ItemId')->value(...)->size(30);<BR><BR><BR><B><I>Hans Ophüls <hop@shoppilot.de></I></B> wrote:</div> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>> But I have a problem with implementing an<BR>> update function.<BR>> It schould select a record from the database<BR>> and insert the data into a widget.<BR>> <BR>> sub hw_update : Local {<BR>> my ($self, $c, $id) = @_;<BR>> <BR>> # Search for the product <BR>> c->model('MyAppDB::Product')->search({id => $id});<BR>> <BR>> # Create the widget and set the action for the form<BR>> my $w = $self->make_product_widget($c);<BR>> $w->action($c->uri_for('hw_create_do'));<BR>> <BR>> ....<BR>> <BR>> sub make_product_widget {<BR>> my ($self, $c) = @_;<BR>> <BR>> #
Create an HTML::Widget to build the form<BR>> my $w = $c->widget('product_form')->method('post');<BR>> <BR>> # Create the form fields<BR>> my $e = $w->element('Textfield', 'itemid' <BR>> )->label('ItemId')->size(30);<BR>> $e->value('4711');<BR>> <BR>> Just where there is '4711' should be the value from the <BR>> column 'itemid'.<BR>> I have tried various expression with<BR>> $c->model('MyAppDB::Product')...<BR>> but I have not found the right way.<BR><BR>I have found a way to do it.<BR><BR>sub hw_update : Local {<BR>my ($self, $c, $id) = @_;<BR>$c->stash->{product} = $c->model('MyAppDB::Product')->search({id => $id});<BR># Create the widget and set the action for the form<BR>my $w = $self->make_product_widget($c);<BR>$w->action($c->uri_for('hw_create_do'));<BR><BR>....<BR><BR>sub make_product_widget {<BR>my ($self, $c) = @_;<BR><BR># Create an HTML::Widget to build the form<BR>my $w =
$c->widget('product_form')->method('post');<BR><BR>if (defined $c->stash->{product}) { # update<BR><BR>my $firstrecord = $c->stash->{product}->next;<BR><BR># Create the form fields<BR>my $e = $w->element('Textfield', 'itemid' )->label('ItemId')->size(30);<BR>$e->value($firstrecord->itemid);<BR>...<BR>} else { # create<BR>...<BR><BR>I don't now if this is best way to do it.<BR>But I have now a widget, which can be used for update and create operation.<BR><BR>But something goes wrong with Umlaut i.e. üäö .<BR>They are stored in the database as Unicode. <BR>Also all Pages are deliverd with utf-8 charset.<BR><BR>But in the update form those characters are not displayed<BR>correctly (In the product list they are displayed correctly).<BR>It seems to me that something goes wrong with my<BR><BR>$e->value($firstrecord->itemid);<BR><BR>Any ideas ?<BR><BR>Hans<BR><BR><BR>_______________________________________________<BR>List:
Catalyst@lists.rawmode.org<BR>Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst<BR>Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/<BR>Dev site: http://dev.catalyst.perl.org/<BR></BLOCKQUOTE><BR><p> 
<hr size=1>Need Mail bonding?<br>Go to the <a href="http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396546091">Yahoo! Mail Q&A</a> for <a href="http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396546091">great tips from Yahoo! Answers</a> users.