CodeIgniter Forums

Full Version: Multiple views. One function or many in the controller?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm fairly new at this and I have a question about style. I have some logic that's basically like this.

If (user says no) then
    Display a view with a radio box asking for a reason.
                o  Not enough time
                o  too much money
                o  Already done this

Depending on feedback, if it's too much money. Display another view
                How much would you be willing to pay? _______

If the user didn't enter a numeric or didn't enter anything, ask again:
                How much would you be willing to pay? _______

THEN, In any case, store all the information provided.

To me it seems like this is all one logical unit, and my first thought was to create just one function that would get called on submit of both these views. But then my question is -- what is the right way to pass the context back and forth from the controller to the views?

The other way to do this would be to have a different submit function for each view, but this seems like the flow could get very complex very quickly. Even with this simple case you'd have 4 functions.

It seems like this is a fairly common thing to do but I haven't found an example, so any help is much appreciated.


El Forum

Have you looked at the user guide for validation?

Try the Codeigniter tutorials on Nettuts, they are essential in my opinion.

Take your time and learn the basics. Write some code that checks what has been returned from a form and go from there.