Monday, September 29, 2008

Re: Form wizard component save data

That is sort of the problem I had.
The component does not to my knowledge handle this at the moment. I
modified it to merge the data from each step so that each step would
contain the data from all steps. On the last step (or in
beforeReceipt) I can then finally save the end-result.

I was in need of a wizard like:
step1 = upload of a file. (csv or xls)
step2 = display part of the file's content and choose what to
"import" (show row 1 and ask which cols to send to database)
receipt = show result of import ("...43 new rows were imported...")

I have got the component to do this now... just got the receipt lest.
I need to make sure it all works and is backwards compatible before I
send my changes to the author. It will of-course be up to him to
decide if my changes are improvements of not. :)

Also, beware, the method you name as the receipt-method will not run
at all. It will only be a "placeholder" for rendering the
corresponding view. Supposedly this will make this action more of a
"redirect when done" kind of thing... but not even that, really. You
will still be at the url of the "wizard". If you want to have any data
sent to your receipt you have to do that in beforeReceipt() which will
execute during the same request just before rendering. But this method
will not have access to any data from the forms automatically, I just
checked. I will have to mod mine to do that too.
beforeReceipt() = method to use for loading data for receipt.ctp
receipt() = method will never run unless you do a POST or redirect to
here (from receipt.ctp)

/Martin

On Sep 29, 1:19 pm, mcphisto <mcphisto1...@gmail.com> wrote:
> My problem is that this form, divided in more pages, saves its data
> all in a unique table. So, if I save data in DB at each step, at the
> end I have 3 new entries with 3 steps.
>
> On 29 Set, 13:07, "martin.westin...@gmail.com"
>
> <martin.westin...@gmail.com> wrote:
> > If you are referring to the component by jaredhoyt then yes the
> > tutorial can be a little fuzzy on some points. It works great, though.
> > Just make sure you read both pages of the article and the comments and
> > any fuzzy bits should be taken care of.
>
> > You have to create a receipt method (i.e. a place to end up after the
> > wizard is done) but you ca call it anything you want and configure the
> > component with the new name.
>
> > As I understand this component (I have only played around with it a
> > bit so far):
> > You do no directly access the session data. The component populates
> > this->data for each step whenever you step back and forth in the
> > wizard.
> > The component expects you to process and save data at each step, I
> > think... Possibly you get all the data available in the receipt... not
> > sure. What I do know is that data entered in step1 is not available to
> > you in step2 (without going behind the components back and accessing
> > the session directly).
>
> > I needed each step to have the data of the previous steps so I had to
> > modify the component a little. And then I had to direct my attention
> > elsewhere for a while and have not finished the wizard I started...
> > that's why my knowledge is so limited.
>
> > /Martin
>
> > On Sep 29, 12:43 pm, mcphisto <mcphisto1...@gmail.com> wrote:
>
> > > Hi all,
> > > I'm installing this component on my application to have a multi-page
> > > form. Everything work, but I really don't know how to save data in the
> > > database. The problem is that I can't find the session variables saved
> > > during the steps. The other thing I don't understand is if I need to
> > > create a function "receipt" in my controller. This part is not
> > > explained on tutorial.
> > > Anyone can help me?
>
> > > Thank you.- Nascondi testo citato
>
> > - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: