$this->temp_validate = array();//global var for validation
function hard_validation($str, $param)
{
list($table, $field) = explode('.', $param);
if ( ...... hard validation $post_array['field1'], $post_array['field2'], $post_array['field3'], $post_array['field4'] .....) {
......
return true;
}
else {
$this->form_validation->set_message('hard_validation', 'My Error Message');
return false;
}
}
function callback_validation_slug($post_array, $primary_key) {
//save post in global va
if (isset($primary_key)) {
$this->temp_validate["id"] = $primary_key;
}
else {
if (isset($post_array['id'])) {
$this->temp_validate["id"] = $post_array['id'];
}
else {
// insert object, id not set
}
}
$this->temp_validate["field1"] = $post_array['field1'];
$this->temp_validate["field2"] = $post_array['field2'];
$this->temp_validate["field3"] = $post_array['field3'];
$this->temp_validate["field4"] = $post_array['field4'];
return $post_array;
}
function my_table()
{
$table = __FUNCTION__;
$this->crud->set_table($table);
....
$this->crud->set_rules("slug","MyFieldName","required|slug|min_length[3]|callback_hard_validation[$table.slug]");
$this->crud->callback_before_update(array($this, "callback_validation_slug"));
$this->crud->callback_before_insert(array($this, "callback_validation_slug"));
.....
}
What to do?
[color=#282828][font=helvetica, arial, sans-serif]Best Regards.[/font][/color]