Yes, something like that. And I think it could be also helpful if you could right about the recommended way to access the login_form's variables in the action used by that form (for example "/login").

Define $login_form = $self->form there also?
Or just get the variables using $c->req->param(...)?

Octavian

----- Original Message ----- From: "Andreas Marienborg" <[EMAIL PROTECTED]> To: "HTML Form Creation,Rendering and Validation Framework" <html-formfu@lists.scsys.co.uk>
Sent: Monday, October 13, 2008 4:50 PM
Subject: Re: [html-formfu] Displaying 2 forms in the same page


=head2 Multiple forms using Catalyst::Controller::HTML::FormFu

Sometimes you need to display multiple forms on a single page. If you
try to use FormConfig on several actions in a chain, or similar, they
all use $c->stash->{form} to store the form, hence you only get the last
form.

One way to work around such problems is to do a little of the work yourself:

In this example we have a login_form that we want on every page
    root/forms/login.yml:
    ---
        elements:
            -
                type: Text
                name: username
    ...

We load this in the top-most auto action:

    package MyApp::Controller::Root;

    use parent 'Catalyst::Controller::HTML::FormFu';

    sub auto : Private {
        my ($self, $c) = @_;

        # We want to utilize alot of the magic that the controller
        # gives us, so therefore we call $self->form like this

        my $login_form = $self->form;
        $login_form->load_config('forms/login.yml');

        # Notice how we put it into another stash var, not 'form'
        $c->stash->{login_form} = $login_form;
    }


Any other page that wants to load another form, can now do so freely:

    package MyApp::Controller::Foo;

    sub edit : Local FormConfig {

    }

Finaly, we need to show both forms:

    root/foo/edit.tt
    [% login_form %]
    <h2>edit</h2>
    [% form %]




Something like that?

If no-one objects, I'll commit it tomorrow


- andreas

On Oct 13, 2008, at 9:44 AM, Oleg Kostyuk wrote:

Andreas, may be you lodged this as doc patch for
HTML::FormFu::Manual::Cookbook and send it to Carl ?

--
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to