On 3/11/06, Bernhard Graf <[EMAIL PROTECTED]> 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
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/