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

前端 未结 6 1256
盖世英雄少女心
盖世英雄少女心 2021-02-12 17:54

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:36

    public function getAction(): ?string
    {
        if (! $this->getRequest()) {
            return null;
        }
        $pathArray = \explode('/', $this->request->getPathInfo());
    
        return \end($pathArray);
    }
    

提交回复
热议问题