Search code examples
impresspages

Modify array beforeCreate


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.


Solution

  • 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!