[Html-widget] How to detect valid _and_ submitted?

Andreas Marienborg omega at palle.net
Fri Sep 8 11:29:07 CEST 2006


     if ( ! $result_note->has_errors and $c->req->method eq 'POST') {


is what I usually do.

andreas

On 8. sep. 2006, at 11.18, Tobias Kremer wrote:

> Ok, I just don't get it: What's the correct way to determine if a  
> form has been
> submitted _AND_ filled out correctly?
>
> There's valid() which returns an array of valid elements - this one  
> is true as
> soon as one of many elements is valid (and I don't want to check if  
> the number
> of array elements equals the number of must-be-valid columns). Then  
> there's
> has_errors() which can potentially be true even if the form hasn't  
> been
> submitted yet (just displayed for the first time). Is there nothing  
> like an
> is_valid_and_submitted() method?
>
> I'm using Catalyst and the HTML::Widget plugin which makes use of the
> indicator() method to hold back validation until the first  
> submission. But
> just doing the following does not work:
>
>   my $w = $c->widget_result( 'my_form' );
>   $c->forward( 'do_it' ) unless $w->has_errors;
>
> When the form is display for the first time, has_errors() is 0, thus
> forward() is executed immediately. The following doesn't work either:
>
>   my $w = $c->widget_result( 'my_form' );
>   $c->forward( 'do_it' ) if $w->valid;
>
> forward() is executed as soon as one field is valid. The following  
> works but
> is quite tedious IMHO:
>
>   $c->forward( 'do_it' ) if !$c->widget_result( 'my_form' )- 
> >has_errors &&
>     $c->request->param( $w->indicator );
>
> So how does one pull this sort of basic functionality off? I'm  
> using the
> latest HTML::Widget 1.08 (Rev.70) from SVN.
>
> Thanks a lot and sorry for posting Catalyst examples but I'm sure
> there are some Cat dudes around here :)
>
> -- Tobias
>
> _______________________________________________
> Html-widget mailing list
> Html-widget at lists.rawmode.org
> http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget




More information about the Html-widget mailing list