EllisLab text mark
Advanced Search
     
Codeigniter and Jeditable
Posted: 26 July 2011 05:46 PM   [ Ignore ]
Joined: 2011-07-24
5 posts

Hi everyone, this is my first post so I’m starting not to with issues.

I’d rather leave here a simple way to use the class to Form_validation with jeditable.

Actually very simple, we extended the run function in the Form_validation class, the following entry.

// Function call
284: function run($group ''$jeditable FALSE)
334:  
// Fix for JEDITABLE
if($jeditable)
{
 $this
->_field_data[$field]['postdata'$this->_reduce_array($_POST['value']$row['keys']);
}
else
{
$this
->_field_data[$field]['postdata'$this->_reduce_array($_POST$row['keys']);  
}                                } 


Now even a change in the controller.

// $this->validated_field are the Post Variables from jeditable
$arr_as_str $this->validated_field['id']'[' .$this->validated_field['value']']'

// is a example
$validation_rules_str 'xss_clean|trim|required|min_length[3]|max_length[20]'

// setting rules
 
$this->form_validation->set_rules($arr_as_str$fieldname$validation_rules_str); 

// Second parameter is True,  otherwise is not run... :)
 
if ($this->form_validation->run($thisTRUE) == FALSE

That was it ..., I hope you enjoy ...smile