[Catalyst] HTML::Widget field name translation in MoreFewer?

Carl Franks fireartist at gmail.com
Tue May 2 14:12:04 CEST 2006


Simon,

I'm not sure that filters are the best way to acheive this.
Are you aware that you can create your own element classes.

For example:
$widget->element( 'My::Textfield', 'foo );

The your create the file HTML/Widget/Element/My/Textfield.pm, make it
a sub-class of HTML::Widget::Element::Textfield, and you can override
the value() or any other method, and can create new methods.

You could also create a web-class of HTML::Widget, and use that
instead, to override behaviours for the whole widget.

I hope this helps,
Carl


On 29/04/06, Vsevolod (Simon) Ilyushchenko <simonf at cshl.edu> wrote:
> Carl,
>
> I've written a Catalyst controller class called MoreFewer (for
> displaying multiple rows of child data, eg, authors of a book). I'm
> trying to use HTML::Widget there, and I've realized that it's not quite
> sufficient for what I need. A field called 'author_last_name_3' should
> use the method 'last_name' to read its value from the data object, so
> the field names are not the same as the widget names.
>
> I can almost do it with custom filters, but I can't pass them parameters
> during their creation. Since each filter has to be using a different
> index, I can't just use a generic class. I'd like to be able to
> initialize a filter with a coderef.
>
> Can you give me some advice on the best way of accomplishing this in
> HTML::Widget?
>
> Thanks,
> Simon
>
> --
>
> Simon (Vsevolod ILyushchenko)   simonf at cshl.edu
>                                 http://www.simonf.com
>
> "Think like a man of action, act like a man of thought."
>
>                          Henri Bergson
>
>



More information about the Catalyst mailing list