CodeIgniter Forums
Fatal error: Call to undefined method Front::run() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Fatal error: Call to undefined method Front::run() (/thread-60573.html)



Fatal error: Call to undefined method Front::run() - El Forum - 04-28-2014

[eluser]solid9[/eluser]
Hi guys,

I'm using HMVC

And I'm having error message below,
Code:
Fatal error: Call to undefined method Front::run() in /home/coder9/public_html/jazauthhmvc/application/modules/front/controllers/front.php on line 137

These are the codes for /front/login/ method
Code:
function login()
{
  $this->form_validation->set_rules('username', 'Username', 'required');
  $this->form_validation->set_rules('password', 'Password', 'required');
  
  //if ($this->form_validation->run() == FALSE)
  if ($this->form_validation->CI->run() == FALSE)
  {
   //If validation has error display form again with error messages.  
   $this->index();
  }
  else
  {
   //If form validation has no error catch $username and $password
   //Call login method
   $username = $this->input->post('username', TRUE);
   $password = $this->input->post('password', TRUE);
   $this->data['remember'] = $this->input->post('remember', TRUE);
  
   if($this->users_model->login($username, $password))
   {
    if($this->data['remember'] == 'accept')
    {
     //if remember-me is selected save to cookie.
     $this->jaz_lib->save_cookie($username, $password);
    
     //Save remember into session.
     $this->session->set_userdata('remember', $this->data['remember']);
    }
    //redirect to front page.
    $this->session->set_flashdata('message', 'Welcome back! ');
    redirect('front/home_page');
   }
   else
   {
    //If login failed display error message.
    $this->session->set_flashdata('message', 'Invalid username or password.');
    redirect('front/home_page');
   }
  }

The error message will show when you try to login without entering a username and password below,
http://coder9.com/jazauthhmvc/

What I'm missing here?

Thanks in advance.




Fatal error: Call to undefined method Front::run() - El Forum - 04-28-2014

[eluser]Tim Brownlaw[/eluser]
Hi,

Is this on line 137?...
if ($this->form_validation->CI->run() == FALSE)

Which HMVC are you using? Wiredesignz or someone elses?

Cheers
Tim


Fatal error: Call to undefined method Front::run() - El Forum - 04-28-2014

[eluser]solid9[/eluser]
wiredesignz ^__^


Fatal error: Call to undefined method Front::run() - El Forum - 04-29-2014

[eluser]Tim Brownlaw[/eluser]
Well I'm guessing that you altered the form validation call to suit using HMVC....

So what I suggest is that you re-read that workaround for that bit...


When somethings not working... go back over the documentation ( at least ) and see what might be wrong.
Did you do all the required steps correctly?

Cheers
Tim


Fatal error: Call to undefined method Front::run() - El Forum - 04-29-2014

[eluser]InsiteFX[/eluser]
Code:
// by David of the Insiders Club
// MY_Form_validation.php - ./application/libraries
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation
{
public function run($module = '', $group = '')
{
  (is_object($module)) AND $this->CI = &$module;
  return parent::run($group);
}

}

// use like this
if ($this->form_validation->run($this) == FALSE)
{

}
else
{

}



Fatal error: Call to undefined method Front::run() - El Forum - 04-29-2014

[eluser]solid9[/eluser]
Thank you insiteFX.


Fatal error: Call to undefined method Front::run() - El Forum - 04-29-2014

[eluser]Tim Brownlaw[/eluser]
@InsiteFX Smile You just had to!