Hook page.create:before, how to edit user input?

Not tested but it should probably look something like this.

class ParentPage extends Page
{
    /**
     * Creates and stores a new page
     *
     * @param array $props
     * @return Page
     */
    public static function create(array $props): Page
    {
        $props['slug'] = $props['content']['title'] . '-' . date('Y');
        
        return parent::create($props);
    }
}

Note:

Since Kirby 3.4 you need to overwrite the create method on the actual page model that is going to be created. Not the parent model!

2 Likes