[Catalyst] html-widget/accessor - by design?

Carl Franks fireartist at gmail.com
Fri Mar 10 17:34:19 CET 2006


I've just added a change to html-widget, so that if you add an Upload
element, then
$widget->enctype( 'multipart/form-data' )
is automatically called (because file uploads don't work without it)

In my change, I've done a test on:
if ( $type eq 'Upload' )

I had wanted to do:
if ( $type eq 'Upload' && not defined $self->enctype )

However, this doesn't work, because if an enctype hasn't been set yet,
enctype() returns the $widget object.
I find this a bit strange - it this behaviour used anywhere?

The enctype() behaviour is defined in widget/accessor.pm
mk_attr_accessors() subroutine
at this line:
return ( $_[0]->{attributes}->{$name} || $_[0] ) unless @_ > 1;

Cheers,
Carl



More information about the Catalyst mailing list