In case you've missed it, you are looking at an older version of the website. Checkout our latest version, we promise you will love it 😍

set_rules

void set_rules(mixed $field [, string $label [, string $rules] ])
Quick Description: Set Validation Rules ( Same as Codeigniter set_rules)

Set Validation Rules works with the exact same way as Codeigniter set_rules. For more you can read: codeigniter validation rules

Important note: If the $field is an array then no automated crud fields will take apart

function example_set_rules() {
 
    $crud = new grocery_CRUD();
 
    $crud->set_table('products');
    $crud->columns('productName','buyPrice');
 
    $crud->set_rules('buyPrice','buy Price','numeric');
    $crud->set_rules('quantityInStock','Quantity In Stock','integer');
 
    $output = $crud->render();
 
    $this->_example_output($output);
}    
Note: The below example is an iframe so it might appeared with a scroll bar. If you like you can view the example on a new tab