How-to: Optimize Symfony's forms' performance?

前端 未结 2 955
鱼传尺愫
鱼传尺愫 2021-02-18 16:14

I have a form that is the bottleneck of my ajax-request.

    $order = $this->getDoctrine()
        ->getRepository(\'AcmeMyBundle:Order\')
        ->fin         


        
2条回答
  •  不思量自难忘°
    2021-02-18 16:36

    I also had the same problem with the entity type, I needed to list cities, there were like mire then 4000, what I did basically is to inject the choices into the form. In your controller you ask the Variants from the database, in a repository call, hydrate them as array, and you select only the id and the name, or title, and then you pass into the form, as options value. With this the database part will be much quicker.

提交回复
热议问题