I am having trouble writing a simple 3-step Wizard.  Basically, I am
trying to figure out the best way to temporary save form inputs in the
model, without writing it to the database until the user finishes step
3 of the wizard and clicks on the Finish button.

What I'm trying to do here is instead of calling
$this->Company->save($this->data) which stores the data into the
database, I am using $this->Company->set($this->data) to temporary
store the form's contents in the Company model without writing to the
DB.  I may be completely misunderstanding the usage of the set()
function, so please correct me if I'm way off base here.  The following
lines (stored in the controller) are executed after the user clicks the
Next button in step 1 of the wizard.

if (isset($this->data['save']))
{
  $this->Company->set($this->data);

  $_SESSION['company'] = $this->Company;
}

The problem is, in step 2 of the wizard, when I try to access the data
stored in the session object, I have to call the data like this:

echo $this->Company->data['Company']['Company']['name'];

instead of:

echo $this->Company->data['Company']['name'];

Running this line:

print_r( $this->Company->data);

produces this output:

Array
(
  [Company] => Array
  (
     [Company] => Array
         (
            [name] => Test
         )
   )
 )

As you can see, the data is not being stored correctly with the
$this->Company->set($this->data) function, as the correct output of the
print_r command should be something like:

Array
(
   [Company] => Array
      (
         [name] => Test
      )
)

Am I on the right track here? Or am I completely bastardizing the
CakePHP framework?  Is this the right way to go about writing a wizard?
 I want to try to keep things simple by storing all the form data in
the Model object, which will then automatically add all the information
into the database when I call:
$this->Company->save($this->Company->data);

Unfortunately, because the Company->set() function doesn't seem to be
storing the data in the way I envisioned it to, the Model is unable to
automatically insert the data into MySQL. I am also unsure if I am on
the right track because when the user clicks the Next button in step 2
of the wizard, I will once again call $this->Company->set($this->data),
but it seems that this will overwrite the existing information stored
from step 1 with the data entered in step 2, which probably means, now
that I think about it, that I am going about this in completely the
wrong way.

I know I can do all this manually by customizing the SQL code in the
Company model, but I want to try to figure out the correct way to do it
so I can take advantage of CakePHP's integration with the database
tables.

Can someone please point me in the right direction?  Are there other
classes/functions that I have overlooked which can be used to
accomplish this?

Many thanks!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to