• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HMVC and form_validation.php?

#11
[eluser]PhilTem[/eluser]
Hm... for the files you sent me I can say, that the controller 'test/test' doesn't extend the MY_Controller class but rather the MX_Controller class.

I don't know about the files that originally made problems, but it may be the same typo? MX and MY look pretty similar when reading quickly Wink

PS: It took me 15min. to find that problem. What I did: Loaded the form-validation in the controller's __construct() and assigned $this to form_validation->CI in the same __construct().

#12
[eluser]Steve Goodwin[/eluser]
Hi Phil,

Yeah I threw that together as quickly as i could to give you some idea of what i was trying to do.

Has that worked for you and does the validation work now?

I've tried based on my interpretation of what you've said and its still not working by putting this in the controllers constructor:

Code:
class Test extends MX_Controller {

public function __construct()
    {
        parent::__construct();

        $this->load->library('form_validation');
        $this->form_validation->CI =& $this;
    }
}

Thanks for your time on this, i'm stuck and have alot to do by the end of the week and a day spent on this problem is really annoying me lol.

#13
[eluser]Steve Goodwin[/eluser]
I managed to sort this by removing the form_validation from the autoload file. Thanks for your time on this much appreciated!

Can i buy you a drink for your help?

#14
[eluser]PhilTem[/eluser]
Well, no, I actually did a little more than that, but I could now nail it down where it all starts. But I don't know yet, why it doesn't work:

In MY_Form_validation you call the parent's construct() method. If you comment everything in your MY_Form_validation class except the public $CI part it will work. And you don't even need to pass a validation-group (which, btw, must not have the module's name in the key, it will work with controller/method).

#15
[eluser]PhilTem[/eluser]
And I found the problem

Your code:
Code:
class MY_Form_validation extends CI_Form_Validation {
  
  function __construct()
  {
    parent::__construct();
  }
  
}

(Important) Code in CI_Form_validation
Code:
class extends CI_Form_Validation {
  
  function __construct($rules = array())
  {
    // Validation rules can be stored in a config file.
    $this->_config_rules = $rules;
  }
  
}

See the difference?

Change your code to
Code:
class MY_Form_validation extends CI_Form_Validation {
  
  function __construct($rules = array())
  {
    parent::__construct($rules);
  }
  
}

and it should work Wink

#16
[eluser]Steve Goodwin[/eluser]
I've followed those instructions and it still doesn't work =[

Perhaps you can package the code back up and send it back over? I'll take a ganders at it and see whats going wrong.

I opened up my validation test code locally and change the following:

My_Form_validation.php

Code:
class MY_Form_validation extends CI_Form_Validation {
  
  function __construct($rules = array())
  {
    parent::__construct($rules);
  }
  
}

Test.php (controller)

Code:
class Test extends MX_Controller {

public function __construct()
    {
        parent::__construct();
        $this->form_validation->CI =& $this;
    }
}

Thanks for your help, this is quite a frustrating problem! lol

#17
[eluser]PhilTem[/eluser]
There was another fix I did (forgot it would have such an impact): Remove the library from autoload.php

Additionally, you can have your altered code here
http://files.ignitedco.de/codeigniter/te..._FIXED.zip

#18
[eluser]Steve Goodwin[/eluser]
thanks can I send you a few drinks for your efforts?

#19
[eluser]PhilTem[/eluser]
I wouldn't mind Wink

#20
[eluser]Steve Goodwin[/eluser]
PM me your details and i'll send a couple your way, thanks for your help.

Code:
if($people_help)
{
  getRewarded();
}
else
{
  echo "No point having a community";
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.