[Catalyst] "update_from_form" and empty fields

Ken Youens-Clark kyclark at gmail.com
Fri Nov 18 21:21:44 CET 2005


On Nov 18, 2005, at 2:10 PM, Ken Youens-Clark wrote:

>> Actually you're probably right.  FromForm 0.03 has been out for a  
>> while so while it could really be either problem, not having  
>> missing_optional_valid is more likely. :)
>
> My version of Class::DBI::FromForm is 0.03, so it looks like I do  
> need to set the "missing_optional_valid => 1" for   OK, so ... how  
> do I do that?  I tried this:
>
>   $c->stash->{'item'}->update_from_form($c->form 
> (missing_optional_valid => 1));

More on this.  I've been poking around the different modules, and I  
think the above should make this work.  A Data::Dumper of "$c->form"  
shows that the "valid" part of the hashref is empty when  
"missing_optional_valid => 1" is present (and without that, the  
"valid" only contains the non-null form elements).  Now when I look  
at the source for "Class::DBI::FromForm," I see that it's only  
checking the "valid" parts, so actually nothing is getting updated:

sub _run_update {
     my ( $me, $them, $results ) = @_;
     foreach my $col ( keys %{ $results->valid } ) {
         if ( $them->can($col) ) {
             next if $col eq $them->primary_column;
             my $val = $results->valid($col);
             $them->$col($val);
         }
     }
     $them->update;
     return 1;
}

Is this a bug in Class::DBI::FromForm for not checking something else  
or one in Data::FormValidator for not populating "valid" with all the  
non-null fields?  (FWIW, I'm up-to-date on both modules.)

ky



More information about the Catalyst mailing list