Is there any way to determine current action (create or edit) in Sonata\AdminBundle\Admin\Admin::configureFormFields()?

后端 未结 6 996
渐次进展
渐次进展 2021-02-12 18:07

I\'d like to create different fields configuration for create and edit actions in Sonata Admin Bundle.

Is there any way to determine it except checking $this->g

6条回答
  •  遥遥无期
    2021-02-12 18:46

    with:

    if($this->getRequest()->get($this->getIdParameter()) == null){
       // create
    } else {
       // edit
    }
    

提交回复
热议问题