[Catalyst] Setting data field to ''
Kevin White
kevin at theconfused.co.uk
Sun Mar 19 02:01:46 CET 2006
Hi Folks,
Hmm, answering my own questions here!
On 19 Mar 2006, at 00:44, Kevin White wrote:
> sub _run_update {
> my ( $me, $them, $results ) = @_;
> my @cols = ( $results->isa('HTML::Widget::Result') ?
> $results->valid :
> keys %{ $results->valid } );
>
> foreach my $col ( @cols ) {
> if ( $them->can($col) ) {
> next if $col eq $them->primary_column;
> if($results->isa('HTML::Widget::Result')) {
> $them->$col( $results->param($col));
> } else {
> #####
> $them->$col( $results->valid($col));
> #####
> }
> }
> }
> $them->update;
> return 1;
> }
Out of curiosity I changed the commeted line to:
if( $results->valid( $col ) eq '' ) {
$them->$col( '' );
} else {
$them->$col( $results->valid($col));
}
And this worked, so I had a look into Data::FormValidator::Results.
In there valid check to see if an array is required as a response. It
will be if valid is called as a method parameter. If this is the case
then valid calls an internal function _arrayify which does a nice
little thing if the given value to arrayify isn't an array ref:
return (length $val) ? ($val) : ();
Hmm... doh!
Not sure if this is working as intended or an issue... anyone know?
Kevin
More information about the Catalyst
mailing list