I see now why my question was not answered. It has been asked about twelve times on these boards and no answer has been found. I'll post what I have found for the sake of anyone following the same route I did.

FormBuilder with Catalyst will not allow you to reference an individual field using any of the following lines:

[% FormBuilder.field.<fieldname>.tag %]
[% FormBuilder.field.<fieldname>.field %]
[% FormBuilder.tag('<fieldname>') %]
[% FormBuilder.field('<fieldname>').tag %]


where <fieldname> is the name of the field you specified in the source file. The following line:

[% FormBuilder.field('<fieldname>') %]

will just give you the name of the field. It basically just returns whatever you have between the quotes.


You can only call individual fields by referring to the array index, like this:

[% FormBuilder.field.0.tag %]

where the 0 is the index number of the field you want.
The index number is determined by the order in which you put the fields into the source file, starting at zero. For example:

name: test

method: post

fields:

# 0

   first_name:

       label:    Client First Name

       type:    text

       required:    1

# 1

   last_name:

       label:    Client Last Name

       type:    text

       required:    1

This source file would put first_name at index 0 and last_name at index 1. The lines with # 0 and # 1 in the example are just comment lines I use to help me remember what the fields index is.

I hope this helps someone else and saves them the time I spent discovering this. If I'm wrong and someone has found an answer, please let me know.

Ascii King wrote:
I can call my fields using this code:
[% FOREACH thing IN FormBuilder.fields %]
[% thing.tag %]
[% END %]

If I have a field named "fullname" I cannot call it individually with either
of the following commands:
[% FormBuilder.field.fullname.field %]
[% FormBuilder.field.fullname.tag %]

I can only call it like this:
[% FormBuilder.field.0.tag %]

I have been over the documentation and I feel I am putting it in the way I
was told. The only thing I can see that might affect it is this bit of code.
    my $form = CGI::FormBuilder->new(
        fields => \...@fields,
        template => {
             type => 'TT2',
             template => 'form.tmpl',
             variable => 'form'
        },
    );

This code fails for me complaining that the variable 'fields' is not scoped
properly. "Global symbol "@fields" requires explicit package name at "


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to