The idea is when I add a new row, one of the field (ID) have to has a default value + Value of another field + date.
Example of ID: IDPeter17112017
So, this is the code I have but it doesn't work, or maybe isn't the best way to do it.
$crud->add_fields('name','email','date');
$crud->callback_before_insert(function ($post_array) {
$name = $name['name'];
$date = $date['date'];
if (empty($post_array['id'])) {
$post_array['id'] = 'ID' . $name . $date;
}
return $post_array;
});
But unfortunetly the name and date does not display...
Any suggestions?
Thank in adavance
Aboslutely doing it wrong. I need to use "Callback_column" for this.
This is what I did and it works like a charm:
$crud->add_fields('name','email','date');
$crud->callback_column('id',array($this,'id_callback'));
$output = $crud->render();
function id_callback($value, $row)
{
return "ID" . $row->name . $row->date;
}
:)