I am a new to codeIgniter and I just got stuck in the very beginning. I am using HMVC extention and while validating I am getting the following error:
Unable
xss_clean is no longer part of form validation in Codeingitore 3
Just remove xss_clean
from your validation roul
$this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check');
If you really, really need to apply that rule, you should now also load the Security Helper, which contains xss_clean()
as a regular function and therefore can be also used as a validation rule.
go to application/config/autoload.php :
$autoload['helper'] = array('security');
Or, before your form validation
$this->load->helper('security');
Hello Guys I found the solution for working with call_backs in hmvc codeIgniter. I would like to post the solution for others.
Solution:
1. Create MY_Form_validation.php file in libraries folder and paste following code in it.
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);
}
}
if ($this->form_validation->run() == FALSE)
to if ($this->form_validation->run($this) == FALSE)
thats all folks..public function pword_check($str)
{
if ($str == 'test')
{
$this->form_validation->set_message( __FUNCTION__ , 'The %s field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}
}
// Its working well
https://github.com/bcit-ci/CodeIgniter/issues/3908
before going to the helper security check on the file application/config/autoload.php
add form_validation in librariies
$autoload['libraries'] = array('form_validation');
and don't forget to add security
$autoload['helper'] = array('security');
try it
The reason for this error is you didn't loaded the security helper the following is the way enable security helper with autoload.php in config folder or you can directly load the helper as mentioned last line of this post
And if, despite everything, you really need it, go to application/config/autoload.php :
$autoload['helper'] = array('security'); Or, before your form validation $this->load->helper('security');
For future searches. There are two 3 things you need to check when this error shows.
Check the name of the callback function if it is the same with the
$this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check
public function pword_check($str){
if ($str == 'test'){
$this->form_validation->set_message('pword_check', 'The %s field can not be the word "test"');
return FALSE;
}
else{
return TRUE;
}
}
*public function pword_check($str){
*set_message('pword_check', 'The %s field...
In codeigniter 2.X you can do this
$this->form_validation->run($this) == TRUE
In 3.x it should be like this
$this->form_validation->run() == TRUE
and you need to add this two line of codes on __construct()
function __construct(){
parent::__construct();
$this->load->library('form_validation');
$this->form_validation->CI =& $this;
}
Add this file on your application/libraries/MY_Form_validation.php
<?php
class MY_Form_validation extends CI_Form_validation{
public $CI;
}
Cheers! See https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/src/f77a3fc9a6fd?at=codeigniter-3.x
https://www.youtube.com/watch?v=pp4Y_bIhASY&list=PLBEpR3pmwCayNcTCUWlUToK4qIQfFQCCm&index=8
For reference.