CodeIgniter Forums
Validation callback bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Validation callback bug? (/showthread.php?tid=66126)



Validation callback bug? - Douglas Fernando - 09-08-2016

Hello team CodeIgniter developers, I would first like to thank you guys for the work done to build this framework.

Would you like to post a bug I found in the validation of the data using a callback function.

When I try to use a callback function to assist in my validations.

The message that appears, appears in this way and does not work:

"There is no error message to the field with the name user_email (check_email).";

NOTE: Check_email is my callback function ...

After much searching on the internet, I found this in a forum:

Solution:

1. Create MY_Form_validation.php file in the libraries folder and paste the following code in it.


PHP Code:
if (! defined 'BasePath')) exit ( 'No direct script access allowed');
class 
MY_Form_validation extends CI_Form_validation
{

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



And change
PHP Code:
if ($this->form_validation->run() == FALSE)

to if ($this->form_validation->run($ this) == FALSE
that's all folks ..

The link to the forum is this:
http://stackoverflow.com/questions/32665715/codeigniter-unable-to-access-an-error-message-corresponding-to-your-field-name/38815609#38815609

Sorry if I was not clear, it is that I am from Brazil and do not speak English, I am using Google translator.


RE: Validation callback bug? - Joel Catantan - 09-08-2016

How do you construct your callback validation?


RE: Validation callback bug? - Avenirer - 09-08-2016

You should have mentioned the fact that the so-called "bug" is happening when you have HMVC CodeIgniter.


RE: Validation callback bug? - InsiteFX - 09-09-2016

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

/**
 * Class MY_Form_validation
 *
 * Save to ./application/librayies/MY_Form_validation
 *
 */
class MY_Form_validation extends CI_Form_validation
{
    public function 
run($module ''$group '')
    {
        (
is_object($module)) AND $this->CI = &$module;
        return 
parent::run($group);
    }

}


// In your Controller

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


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

}
else
{



That is how it is done.


RE: Validation callback bug? - Douglas Fernando - 09-09-2016

(09-09-2016, 05:10 AM)InsiteFX Wrote:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

/**
 * Class MY_Form_validation
 *
 * Save to ./application/librayies/MY_Form_validation
 *
 */
class MY_Form_validation extends CI_Form_validation
{
    public function 
run($module ''$group '')
    {
        (
is_object($module)) AND $this->CI = &$module;
        return 
parent::run($group);
    }

}


// In your Controller

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


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

}
else
{



That is how it is done.

This need not be so, this is not a BUG of codeigniter?

I'm using the 3.0.6 version.


RE: Validation callback bug? - InsiteFX - 09-10-2016

Correct and that is the code for the Form_validation to work with Modules.

Wiredesignz - Modular Extensions - HMVC


RE: Validation callback bug? - Douglas Fernando - 09-10-2016

(09-10-2016, 12:15 PM)InsiteFX Wrote: Correct and that is the code for the Form_validation to work with Modules.

Wiredesignz - Modular Extensions - HMVC

I did not understand What you mean, the codeigniter 3.0.6 does not use MVC ?


RE: Validation callback bug? - InsiteFX - 09-11-2016

CodeIgniter is a MVC Framework HMVC is a add on for CodeIgniter, I think you are confused here.