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

Sebastian Riedel sri at oook.de
Fri Mar 10 18:12:18 CET 2006


10.03.2006 17:34 Carl Franks:

> 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;

We use chained accessors for everything, it's one of the design  
fundamentals of H::W.


--
sebastian




More information about the Catalyst mailing list