[Catalyst] Need HTML Widget And Validation Assist

Matt S Trout dbix-class at trout.me.uk
Sun Apr 16 21:49:58 CEST 2006


dennis wrote:
> Read the docs, coded, recoded...
> Hours later.....
> OK, I admit, my brain is on strike. I am doing something wrong but haven't 
> found it yet. I am trying to validate data and redisplay the data in same 
> form.
> 
> My simple template:
> <form method="post" id="quote_edit" action="/quote/edit">
> <h3>Type Your Quote Here</h3>
> <textarea name="quote" cols="60" rows="3" wrap="soft"></textarea>
> <h3>Author</h3>
> <input type="textfield" name="author" size="60">
> <input type="submit" value="OK">
> </form>
> 
> My app code:
> sub edit : Path('/quote/edit') {
>   my ( $self, $c ) = @_;
> 
>   $c->log->debug("In sub edit : Path('/quote/edit')");
> 
>   my $params = $c->request->params;
>   my $widget = $c->widget('quote_edit');
>   $c->stash->{template} = "text/quote_edit.tt";
>   $c->stash->{params} = $params;
> 
>   # Add some constraints
>   $widget->constraint('All', 'quote' )->message('Quote is required');
> 
>   if ($c->req->method eq 'POST') {
>     $c->log->debug("form quote_edit was submitted')");
> 
>     my $result = $widget->process;
>     my @invalid_fields = $result->have_errors;

Why not set indicator and use $c->widget_result at documented in the Plugin?

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list