[Catalyst] Problem with TT view and form.field

Jason Kohles email at jasonkohles.com
Thu Jan 17 14:49:29 GMT 2008


On Jan 17, 2008, at 2:39 AM, Peter Sørensen wrote:

I don't know much about FormBuilder, however...

> The output is OK but as I understood the docs it should also
> be possible to access this directly.
>
> [% fields %]  -  List of fields
> [% field  %]  -  Hash of fields (for lookup by name)

These are actually exactly the same method in CGI::FormBuilder, which  
says:

*param  = \&field;
*params = \&field;
*fields = \&field;
sub field {

>
> Lets say I have a field named
> firstname then it should be possible to do:
>
> [% form.fields.firstname.label %]


The source for CGI::FormBuilder says that field, if called without an  
argument, will return "an array of the names in list context, and a  
hashref of name/value pairs in a scalar context".  This is problematic  
behavior with TT, as TT always uses a list context, so form.fields and  
form.field are both going to return an array of field names.

Looking at the source though, it looks like you should be able to get  
at them this way:

[% form.field( 'firstname' ).label %]

-- 
Jason Kohles, RHCA RHCDS RHCE
email at jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the Catalyst mailing list