Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]ion_auth and HMVC - form validation problem
#1

[eluser]Cgull[/eluser]
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:
Code:
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.
Code:
<div id="login_form">
&lt;?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));
?&gt;
<div >
<img src="&lt;?php echo site_url('assets/img/login.gif'); ?&gt;" alt="Login" />
</div>
<div  left; font-size:11px; font-weight:bold;padding-top:25px;margin-right:45px">LOGIN</div>

<div left">
&lt;?php echo form_label('Cellphone', 'cellphone', array('class'=>'login-label')); ?&gt;
</div>
<div class="span2"  padding-top:10px">&lt;?php echo form_input('identity', set_value('identity', ''), 'placeholder="cellphone no" class="span2 phone" id="cellphone"'); ?&gt;</div>

<div left; margin-left:10px">&lt;?php echo form_label('Password', 'password', array('class'=>'login-label')); ?&gt;</div>
<div class="span2"  padding-top:10px">&lt;?php echo form_password('password', '', 'placeholder="password" class="span2" id="password"'); ?&gt;</div>
<div class="span1" >&lt;?php echo form_submit($send); ?&gt;</div>
&lt;input type="hidden" name="submitLogin" value="1" /&gt;
&lt;?php echo form_close(); ?&gt;
<div class="clearfix"></div>
</div>
[removed]
$(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.');
}
});
[removed]

I have a few problems:

1.
I read through the HMVC documentation and added these lines to the MY_Controller file:
Code:
$this->load->library('form_validation');
$this->form_validation->CI =& $this;

I created a MY_Form_validation file in: application/libraries:
Code:
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

2. 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

Please, can someone help with that?

I am struggling for days now to have this login system working.

You can see from previous posts of mine today that I tried a few ways to make this work.
#2

[eluser]Cgull[/eluser]
I found out that the login form is not submitting with the jquery, why is that?
#3

[eluser]Cgull[/eluser]
Oh My God !!!

Found the problem, it was on the form open declaration, put a bracket in the wrong place:
Code:
echo form_open(site_url('auth/login', $attr);
Should be:
Code:
echo form_open(site_url('auth/login'), $attr);




Theme © iAndrew 2016 - Forum software by © MyBB