Jump to content


Dankof

Member Since 18 Nov 2017
Offline Last Active Nov 21 2017 01:25 PM
-----

Topics I've Started

Field with a default value and field value

18 November 2017 - 09:15 AM

Hello all,

I'm trying to create a field with a default value + Value of another field + Date of insert
 

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;
});


Any suggestions?

Thank you in advance!