Welcome Guest, Not a member yet? Register   Sign In
Please Help with Form Validation Hmvc
#1

I am Using HMVC with Codeigniter 3.
I am trying to make custom validation callback function and its not working with HMVC.
I get solution from searching in google like.
PHP Code:
class MY_Form_validation extends CI_Form_validation {

    function 
run($module ''$group '')
    {
        (
is_object($module)) AND $this->CI = &$module;
        return 
parent::run($group);
    }



But its not working for me.
Help me
Reply
#2

Any One?
Reply
#3

I presume you are using WireDesigz HMVC. Assuming this, callbacks are an issue with it but easily soluble.

In the docs for HMVC it says that you need to :

Quote:When using form validation with MX you will need to extend the CI_Form_validation class as shown below,

Code:
<?php
/** application/libraries/MY_Form_validation **/
class MY_Form_validation extends CI_Form_validation
{
   public $CI;
}
before assigning the current controller as the $CI variable to the form_validation library. This will allow your callback methods to function properly.

You can read about it here in full: https://bitbucket.org/wiredesignz/codeig...sions-hmvc

There are also lots of good examples to solve this: http://stackoverflow.com/questions/27923...ot-working

I hope this helps,

Best wishes,

Paul.
Reply
#4

(This post was last modified: 10-08-2015, 09:22 PM by wolfgang1983.)

Make sure that this code below is in application/libraries/MY_Form_validation.php


PHP Code:
<?php

class MY_Form_validation extends CI_Form_validation {

    function 
run($module ''$group '') {
        (
is_object($module)) AND $this->CI = &$module;
        return 
parent::run($group);
    }

  


Second when using callbacks with HMVC must include $this variable as shown below.


PHP Code:
public function index() {

$this->load->library('form_validation');

$this->form_validation->set_rules('something''Something''required|callback_test');

// Must include $this variable 

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

} else {

}

}

public function 
test() {

$this->load->library('form_validation');

if (
$this->model_something->can_loggin() == TRUE) {

return 
TRUE;

} else {

$this->form_validation->set_message('test''Cannot Login');

return 
FALSE;

}


There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB