[Dbix-class] DBIx::Class::HTMLWidget enhancement

Brandon Black blblack at gmail.com
Mon Mar 13 18:43:36 CET 2006


On 3/11/06, Bernhard Graf <dbic at augensalat.de> wrote:
> I'd like to have DBIx::Class::HTMLWidget set my widget element's
> maxlength if available from DBIC result_source and appropriate for the
> widget element.
>
> I attach my changes here.
> This is not very much tested, but works for me.
>
> What do you think?

Beware that the "size" in column_info is data-type-dependant.  For
char/varchar it means string length, but for numeric types it could be
the precision, for instance.  There's probably not a perfect generic
way to handle that for all possible db's, but you might want to, for
instance, only set the widget maxlength based on "size" if("data_type"
=~ /char/i) or something like that, to avoid setting an incorrect one
in other cases.

Also, I'm not sure what "size" would be returned for the sizeless
character types, like varchar with no length specified, or "text" in
Pg.  Perhaps not setting maxlength if size < 1 might be a good safety
check for that.

-- Brandon



More information about the Dbix-class mailing list