When customizing the insert I see docs refer you to "$e["on_insert"] = array("add_client", null, false);", but they are not clear on the 2nd argument. Does anybody know what the 2nd argument is for? Also I need to send the username of the person logged in to the function for insert, so how do you alter $data? Docs aren't totally clear on the 3rd argument either. If set to true I call my function, if false, does it not call the function. I must be misreading something.
The `on_insert` takes 3 params (<function-name>, <class-object> or <null-if-global-func>, <continue-default-grid-operation>)
The second argument is passed if your callback function is member function of some class, and class object is passed there.
All the posted $data from client is received in callback function, which can be used for custom insert logic.
function add_client($data)
{
mysql_query("INSERT INTO clients
VALUES (null,'{$data["params"]["name"]}'
,'{$data["params"]["gender"]}'
,'{$data["params"]["company"]}')");
}
If you pass last argument as true, functions will act as a data filter and insert/update in `->table` will be performed by grid after your function.
Refer custom-events.php for more help.
ok that makes sense, but still not clear on how I can change $data before it is passed to the function to include variables I may need to add.