[Catalyst] Any recommendations for multiple forms in catalyst
(have been using HTML::FormFu)?
Carl Franks
fireartist at gmail.com
Fri Jul 4 08:20:31 BST 2008
2008/7/4 Tomas Doran <bobtfish at bobtfish.net>:
>
> On 3 Jul 2008, at 09:05, Carl Franks wrote:
>>
>> I'm guessing that in step 3, your $c->stash->{form} is the one created
>> by the FormConfig action - in which case it's the same form used for
>> step 1.
>> It won't validate the submitted parameters, because it doesn't know
>> about any of the fields you generated in step 2.
>> What you need to do is again generate the same form as step 2, and use
>> that to validate the submitted parameters.
>>
>
> I'd disagree. At each step, you want to validate where you got so far, and
> if that validation goes well, move on - otherwise, move back...
I think there's been either a lacking in my explanation, or a lacking
in your interpretation - if you follow my posted code, it does exactly
what you describe.
Display form 1
-> if valid goto form 2
-> if not valid redisplay form 1
Display form 2
-> if valid, use the data
-> if not valid, redisplay form 2
This is exactly what HTML::FormFu::MultiForm does, but makes it more
simple, as you can do it all within a single Catalyst action - it also
encrypts previous form's data within a hidden field, so you don't need
to revalidate earlier data.
The bit I suspect the OP was getting wrong, was trying to validate
form 2's submission, using form 1.
However, rather than suggest a new module - to get the job done I
suggested what I hoped would only be a minor code change (based on
typical formfu usage, as the OP didn't give any code).
Cheers,
Carl
More information about the Catalyst
mailing list