[Catalyst] Feature request HTML::Widget

Sebastian Riedel sri at oook.de
Wed Feb 1 00:36:43 CET 2006


31.01.2006 22:14 Thomas Klausner:

> Hi!
>
> I've got a feature request for HTML::Widget. I can send a patch, but I
> want to check before I code for the trash bin...
>
>> From time to time (or rather often) I need to do something with the
> elements of a widget, after creating it. I.e. I have a $widget and  
> want
> to access all or some elements.
>
> Currently the only way to do this seems to be to iterate of the  
> ARRAYREF
> returned by $w->{_elements}. Which means one has to directly access  
> the
> hash the $widget-object is based on. And to access 'private' data
> (according to the underscore).
>
> So I propse to add the following:
>
> - a simple accessor 'get_elements' which returns the ARRAYREF
>
> Additionally, I'd like to be able to get single elements by name.
> like so: $widget->get_element('email');
> To implement this, one would need to store the elements not only in
> _elements, but also in a hash. And add some accessors.
>
> This would result in some double assignments in HTML::Widget (but  
> it are
> only refs). OTOH, users of HTML::Widget wouldn't need to either  
> drag the
> hashref around on their own, or iterate over the list of elements just
> to get one or two.
>
> As I said, I can send patches etc, but I'll only write them after some
> discussion/an OK by sri.

We've discussed this exact feature on #catalyst yesterday, and all  
agreed that we need it.

     $widget->get_element('email')

This wouldn't work because the following is valid.

     my $w = HTML::Widget->new('foo');
     $w->element( 'Textfield', 'email' );
     $w->element( 'Textfield', 'email' );


--
sebastian




More information about the Catalyst mailing list