Hi!
I'm relatively new to CodeIgniter and the MVC philosophy in general, so I'm trying to clarify this before I make any bad habits.
I have an application that registers. Users. Currently, the flow is like this:
- User navigates to the "somewebpage/register", which loads the "register" function of the controller
- Controller checks to see if the form is submitted - if it was not, show them the form, otherwise, call the "register" function of the "users" model
- Users model checks to see if the username is already taken. If it is, it returns an errorcode (defined as a PHP constant) for that error.
- If the username wasn't already taken, the model registers the user and returns TRUE.
- Controller collects what the "register" function of the model returns and shows an error page, a success page, or a database failure page based on the errorcode.
As you can see, I tried to move as much logic as possible into the model. The only logic that I wasn't able to relocate was that of the form validation, as CodeIgniter seems to force you to put it into the Controller. (Unless anyone knows a way around this)
Is this the way I should be developing with CodeIgniter, or with MVC in general?
Thanks in advance for any help.