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

后端 未结 6 1086
灰色年华
灰色年华 2021-02-12 18:31

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 19:09

    I use this :

    $creationMode = ($this->id($this->getSubject()))?(false):(true);
    if ($creationMode){
     //Ok
    }
    

提交回复
热议问题