insert custom value to table using grocerycrud Add/Edit

2k views Asked by At

I have a table customer with fields id,name,nickname.. I'm using grocery crud for add/edit. The field nickname should be automatically created based upon the name field. Can anyone suggest what can be done to accomplish this

1

There are 1 answers

0
Phil On BEST ANSWER

You can accomplish this by using the callback_before_insert function of grocerycrud.

Here is a link to the description: callback_before_insert

Before you render your output add this:

$crud->callback_before_insert(array($this,'create_nickname_callback'));

Add the callback method:

function create_nickname_callback($post_array) {
$post_array['nickname'] = your_nickname_value;
return $post_array;

}