Re: [CDBI] Call a has_a rel's inflate/deflate method explicitly.
[prev]
[thread]
[next]
[Date index for 2005/11/04]
On 11/4/05, Matt S Trout <d
> Looking at _deflated_column,
>
> $meta->args->{deflate};
>
> should do the trick.
>
Yep that works. I was forgetting the "args" . What made me curious
was my meta_info hash has "DUMMY" for deflate and inflate methods
which I set to code refs.
Anyway, in case anyone is curious, I needed this (rather than just
saying $self->_attr($col) ) because I want to call a custom deflate
for text iputs when editing datetime columns. Time::Piece stringifies
like localtime and it never passes the validatiton like that or is it
in an editable form. So i specified the has_a like:
__PACKAGE__->has_a("created" =3D> 'Time::Piece',
inflate =3D> sub { Time::Piece->strptime(shift, "%Y-%m-%d %T") },
deflate =3D> sub { my $tp =3D shift; return $tp->ymd.' '.$tp->hms; =
},
deflate4input =3D> sub { my $tp =3D shift; return $tp->ymd.' '.$tp-=
>hms; },
);
Then hacked AsForm::_to_textfield , to check for object and
deflate4Input code ref.
Thanks, Matt.
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi