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

Vsevolod (Simon) Ilyushchenko simonf at cshl.edu
Thu May 4 02:22:24 CEST 2006


Carl,

Thanks for your answer! I was actually trying to avoid creating my own 
subclass for each type of input field. I can almost do what I want if
I create HTML::Widget::Indexed that stores the value of index (1, 2, 3 
etc), but I run into problems when I try to retrieve the value of a 
particular element. If the element knew about its "parent" widget that 
stores the value of the index, it would be easier, but it does not.

I can show up later on IRC to discuss this - let me know what time is 
good for you.

Thanks,
Simon

Carl Franks wrote on 05/02/2006 08:12 AM:
> 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
>>
>>
> 
> 

-- 

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