I am developing a site with Codeigniter 2.1.3
I am using HMVC to create ion_auth modules.
I am trying to separate my frontend and backend login system.
I created two modules for ion_auth: application/modules/auth - for the frontend application/modules/admin - for the backend
Both have the same files, except the admin auth controller is calling a different login view.
My homepage view calls the login view like this:
echo Module::run('auth/login');
Both auth controllers extend Frontend_controller which extends MY_Controller. MY_Controller is in application/core and it extends MX_Controller.
The login view for the frontend is using ajaxForm to submit the form:
<div id="login_form">
<?php
$attr = array('class'=>'form-inline', 'id'=>'loginForm');
$send = array('class'=>'btn btn-inverse', 'name'=>'signin', 'value'=>'Sign In');
echo form_open(site_url('auth/login', $attr));
?>
<div >
<img src="<?php echo site_url('assets/img/login.gif'); ?>" alt="Login" />
</div>
<div left; font-size:11px; font-weight:bold;padding-top:25px;margin-right:45px">LOGIN</div>
<div left">
<?php echo form_label('Cellphone', 'cellphone', array('class'=>'login-label')); ?>
</div>
<div class="span2" padding-top:10px"><?php echo form_input('identity', set_value('identity', ''), 'placeholder="cellphone no" class="span2 phone" id="cellphone"'); ?></div>
<div left; margin-left:10px"><?php echo form_label('Password', 'password', array('class'=>'login-label')); ?></div>
<div class="span2" padding-top:10px"><?php echo form_password('password', '', 'placeholder="password" class="span2" id="password"'); ?></div>
<div class="span1" ><?php echo form_submit($send); ?></div>
<input type="hidden" name="submitLogin" value="1" />
<?php echo form_close(); ?>
<div class="clearfix"></div>
</div>
<script>
$(function()
{
var options = {
target: '#login_form',
success: showResponse // post-submit callback
};
$('#loginForm').ajaxForm(options);
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
});
</script>
I have a few problems:
Problem One: I read through the HMVC documentation and added these lines to the MY_Controller file:
$this->load->library('form_validation');
$this->form_validation->CI =& $this;
I created a MY_Form_validation file in: application/libraries:
class My_Form_validation extends CI_Form_validation()
{
public $CI;
}
After doing this when I go to my homepage I get this error: Cannot access protected property CI_Form_validation::$CI in C:\sites\tl\application\core\MY_Controller.php on line 12
Problem two: If I don’t do these form validation changes and try to submit the login form on the homepage it opens the login view again in a new page with no errors. It looks like it is not using jquery to submit the form
Problem three: It looks like the login form does not use the jquery ajaxForm to submit the form. I don't understand why.
Please, can someone help with that?
I am struggling for days now to have this login system working.