0

So my intention is as follows:

  1. Present a form (~the view) to be filled out: (Book request details)
  2. Display the results for review, after some other background work has been done (looking up the author and genre etc)
  3. have the user "approve"

Now normally, I use CodeIgniter's form validation flow as follows:

  1. in the Controller, the first check is whether the form is valid (e.g. filled in the title?)
  2. if that's good, then do whatever next, usually display a success form.

But that only allows two views.

The problem is that the third form being submitted is not the same as the first/second and so cannot be treated in the same controller method.

The problem is this: Now that the user has "approved", I have a couple of data elements to send on. So I'd have to bury them as hidden fields in the third view so they can be POSTed to the final method. Am I making sense?

Maxcot
  • 1,513
  • 3
  • 23
  • 51

1 Answers1

1

Sessions would be useful here. Every form can be validated in separate controller method. On succesful validation, add data to session array:

$_SESSION['book_order'] = array (
    'data_form_1' => 'some data...',
    'data_form_2' => 'some data...',
    'data_form_3' => 'some data...'
);

Extend it as per your requirements... I've used the native PHP syntax, but you could utilise CI's session class. You can use hidden fields too, but perhaps doing it with sessions is easier and more scalable.

Aidas
  • 1,213
  • 2
  • 10
  • 16
  • Ok, that sounds doable. But are there not some limits on session memory space? 4kb or something. It sounds like it's using valuable resources...? – Maxcot Mar 13 '14 at 19:55
  • Or maybe not... http://stackoverflow.com/questions/4649907/maximum-size-of-a-php-session – Maxcot Mar 13 '14 at 21:28