Hey all!

I am trying to figure out the most elegant way to build/include multiple forms in one page using Catalyst::Controller::FormBuilder.

Right now I am doing it as follows...

In my controller:

  sub foo : Local Form
  {
    my ( $self, $c ) = @_;

    # Form that actually belongs to "foo"
    my $form = $self->formbuilder;

    # Form for the search bar, belongs to "foo_search"
    my $search_form = $c->forward('foo_search');
  }

  sub foo_search : Local Form
  {
    my ( $self, $c ) = @_;

    # Form that belongs to "foo_search"
    my $form = $self->formbuilder;

    # Return the search form
    return $form;
  }


In the "foo.tt" template:

  <!-- Should be the "foo_search" form -->
  [% INCLUDE foo_search.tt %]

  <!-- Should render the "foo" form -->
  [% FormBuilder.render %]


In the foo_search.tt template:

  <!-- Should render the "foo_search" form -->
  [% FormBuilder.render %]


What I end up with when viewing the "foo" action page is two "foo_search" forms. I understand why this happening, from an internals standpoint, but I am not sure how to get around it without ugly hacking. I would like to be able to keep the niceness of the "Form" pragma in the controller and all the cool things that go along with it.

Has anyone found a good way to do this? What about if I wanted to build two different forms from within one page directly in the action (not using forwards)?

Is the general rule of thumb to only use the "Form" pragma if there will only be one form, and use FormBuilder directly (so I can choose a unique variable namespace for each) if there will be multiple?

Thanks!
Danny

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to