[Catalyst] Solved (mostly) the display problem,
still fighting for FormBuilder
Joe Landman
landman at scalableinformatics.com
Sun Dec 31 06:01:36 GMT 2006
In my zeal to code up the application I managed to delete the RenderView
bit. You know, the one line that reads:
sub end : ActionClass('RenderView') {}
in the root controller.
Replacing that immediately fixed the display problem, though now I am
back to the FormBuilder issue. I am having a problem with some of the
documentation (will file a bug against what I found). The docs suggest
something that looks like this (in TT, I hand converted this to Mason).
[% FOREACH field IN form.fields %]
<div id="[%- field.name -%]">
<div class="label">
[% field.required
? qq(<span class="required">$field.label</span>)
: field.label
%]
</div>
This presumes that $c->form->fields is the correct array ref to iterate
over. As I have discovered, it is not. It is $c->form->fieldrefs. So
my Mason code looks something like this:
% foreach $field (keys %{$form->{fieldrefs}})
% {
<% $field |h %>
% }
and it spit out my username and password fields quite nicely. By
Data::Dumping the form, I saw this:
> 'fieldrefs' => {
> 'password' => bless( {
> '_cache' => {
> 'type' => 'text'
> },
> 'cleanopts' => 1,
> 'selectname' => 1,
> 'sticky' => 1,
> 'name' => 'password',
> '_form' => $VAR1,
> 'selectnum' => 5
> }, 'CGI::FormBuilder::Field::text' ),
> 'username' => bless( {
> '_cache' => {
> 'type' => 'text'
> },
> 'cleanopts' => 1,
> 'submit' => 'Login',
> 'name' => 'username',
> 'size' => '40',
> 'password' => $VAR1->{'fieldopts'}{'username'}{'password'},
> 'selectname' => 1,
> 'sticky' => 1,
> 'required' => '1',
> '_form' => $VAR1,
> 'label' => 'User name',
> 'type' => 'text',
> 'selectnum' => 5
> }, 'CGI::FormBuilder::Field::text' )
which suggests that the correct dereference for the [%- field.name -%]
like things is actually
$form->{fieldrefs}->{$field}->{name}
Has anyone else seen this? Or does TT work in some magical other manner
so it hides all of this from us?
Where I am now is that a call to $form->render doesn't seem to do much.
Will work on it some more, I am assuming I have some additional pilot
error here as well.
Thanks.
--
Joe Landman
landman |at| scalableinformatics |dot| com
More information about the Catalyst
mailing list