Modify array beforeCreate

50 Views Asked by At

I am trying to modify array before create:

'beforeCreate' => function($postData){  
    $postData['slug'] = Event::slugify($postData['name']); 
    return $postData;},

In Grid, but it doesn't seems to work.

when I print $postData I can see it on array but is not inserting in database, slug is still empty.

1

There are 1 best solutions below

0
Mangirdas Skripka On BEST ANSWER

Because this is an event. You can't change data in event. Event is used to do some actions on that event. If you want to change date, use filter: createFilter. It is described in the documentation: https://www.impresspages.org/docs/grid

have a nice weekend. Cheers!