Welcome Guest, Not a member yet? Register   Sign In
need some help Grocery CRUD form validation

hi all,

first, i have started learning PHP and frameworks CodeIgniter & Grocery CRUD, i registered on Grocery CRUD forum but i can't make a new Topic and also can't reply to any topic ?? so i am here to ask this question related to Grocery CRUD.

i want to validate an entry before insertion from a table. ( for some reason, i do not want to use any dropdown and set_relation ). need some code how to achieve it.

1) i have two tables a) employees and b) departments
2) employees table contain a column DeptID which is same as in departments table
3) when user enter DeptID, the method check and get column DeptName on a callback_column, this will not only disply the name of department but also verify the DeptID column value
4) if not present, raise an error like "Error: Invalid Deparment ID... " otherwise allow INSERT / UPDATE

please inform, when we can create Master/Detail like Forms using Grocery CRUD?

kindly help me.

Sorry, forgot to mention here what i did... please find below

public function manage_employees()
   $crud = new grocery_CRUD();

   $crud->columns('EmployeeID', 'EmployeeName', 'DeptID', 'DeptName', 'Salary', 'Commission', 'Total');
   $crud->display_as('EmployeeID','Employee Code')
     ->display_as('EmployeeName','Employee Name')
     ->display_as('DeptID','Department ID')
     ->display_as('DeptName','Department Name') /* NOT A DATABASE COLUMN */
     ->display_as('Total','Total Salary');  /* NOT A DATABASE COLUMN */
   $crud->set_subject('Employees Management');
   $crud->callback_column('Total',array($this,'totalSalary')); /* To display Total Salary */

   $output = $crud->render();

public function totalSalary($value, $row)
    return $value.($row->Salary + $row->Commission);

Theme © iAndrew 2016 - Forum software by © MyBB