setting default value in symfony2 sonata admin bundle

后端 未结 4 2021
清歌不尽
清歌不尽 2020-12-28 17:08

how can i set default value in sonata admin bundle the data option is missing in configureFormFields method

protected function configureFormFields(FormMappe         


        
4条回答
  •  忘掉有多难
    2020-12-28 17:43

    I presume you've probably already solved this by now, but as a reference to anyone else you can override the getNewInstance() method and set the default value on the object:

    public function getNewInstance()
    {
        $instance = parent::getNewInstance();
        $instance->setName('my default value');
    
        return $instance;
    }
    

提交回复
热议问题