Oh.. Ya, I got it... filtering is just filtering result before displaying into table (same as searching by query).
So, my query about validation only.
Just like in codeigniter we set rule as
$this->form_validation->set_rules('name', 'Name', 'trim|max_length[50]|required|is_unique[company.name]');
which can be done in GC as, (I guess it's correct)
$crud->->set_rules('name', 'Name', 'trim|max_length[50]|required|is_unique[company.name]');
with this my function in controller goes like this:
function view_company(){
$this->check_logged_in();
$crud = new grocery_CRUD();
/*set theme and table*/
$crud->set_table('company');
/*column to be in displayed table and fields for view/add/edit */
$crud->columns('Id','Name','Email','Address','LogoURL');
$crud->fields('Name','Description','Email','Address','LogoURL');
$crud->display_as('LogoURL','Logo');
/*required field in add/edit*/
$crud->required_fields('Name','Address');
$crud->set_field_upload('LogoURL','images');
/*form validation rules*/
$crud->set_rules('name', 'Name', 'trim|max_length[50]|required|is_unique[company.name]');
$crud->set_rules('description', 'Description', 'trim|max_length[255]');
$crud->set_rules('email', 'Email', 'trim|valid_email|max_length[255]|is_unique[company.email]');
$crud->set_rules('address', 'Address', 'trim|required|max_length[255]');
$output = $crud->render();
$crud->set_subject('Company');
$this->load->view('admin/view/company',$output);
}
Now when I try to add new record or edit existing row, it's not validating all fields as mentioned in set_rules above. Just required field works, that too due to addition of $crud->required_fields().
I'm not getting what's more need to be done so as to validate form data with above rules during edit and add new.
(I'm unable to understand usage of various callback functions. Which one to use where and how?)
I tried some thing like..
$crud->set_rules('name', 'Name', 'callback_validate_company_data');
function validate_company_data(){
}
But not getting what to write in validate_company_data(). I guess every rule need not be checked manually, instead we can take advantage of codeigniter's $this->form_validation->set_rules() or some other similar feature in GC. (in codeigniter we use $this->form_validation_run() . Is there anything similar needed in GC? If yes, what's it? And if not, why is above code not working?)
Please help me to understand, if possible with full example, how to complete above code so the form validation works perfectly as in codeigniter.
Thanks.