I’m playing around with ME, trying to get a feel for it and how to best integrate it. I am finding that I need to think quite differently about how I structure things when using ME. I’m a hobbyist with CI experience, but a complete noob to ME.
One of the things I am trying to understand is the best way to use ME for my projects: should I have a set of application MVCs that calls upon functional modules to do the heavy lifting (this is, using modules like “uber-libraries”), or should a project be made up ALL from modules, with one module being the main application manager.
Currently, I am trying out the former - uber-libraries - and it is working pretty well.
One issue I have with this approach, is how to get a controller in a module to invoke a method in a application controller. For example, I have a module, “User”, that does all the login/logout stuff (using Redux Auth). When logging in, the User module is invoked by an application/view (module::run) loaded by a controller in application/controller. The User module loads a view to display a login form. The form is submitted to the module for validation and authentication (all User logic is in the User controller) and if login successful, redirects to the homepage, or if unsuccessful redirects to the application/controller to display the login page again (with some flashdata feedback).
However, if there is a form validation error, I’m not sure what I should do. I can reload the login form, but since the validation is done in the module, loading the modules login partial view replaces the whole page. So this isn’t a solution. On the other hand, I could try to reload the whole page by invoking the application/controller from the module controller doing the validation, but I can’t seem to do that (also, not sure this will retain and display the login form’s validation errors - I’m hoping it will).
I tried
$this->user->login()
and
$this->CI->user->login()
but both returned non-object errors.