简体   繁体   English

Symfony2:通过创建表单来表现

[英]Symfony2: performance with form creation

I have a system that generates forms dynamically with Symfony2. 我有一个使用Symfony2动态生成表单的系统。 It works fine with little forms, but when I have collection of hundreds of elements then it may take up to 10s to generate the page. 它以很少的形式工作正常,但是当我收集了数百个元素时,可能最多需要10秒钟才能生成页面。

Looking in the profiler, a lot of time is spent doing $form->createView() (more than 5s in debug mode). 在探查器中查看,花费大量时间执行$ form-> createView()(在调试模式下超过5s)。 As Symfony2 processes fields like forms in a recursive way, I think that there might be a lot a processing for a single fields, but can that not be optimized ? 当Symfony2以递归方式处理诸如表单之类的字段时,我认为单个字段可能会有很多处理,但是这是否可以优化?

I noticed another strange behavior with 'choice' fields: with huge collections, the more values there are, the more time it takes (I tested it by limiting to 0, 1, 2, all values). 我注意到“选择”字段存在另一种奇怪的行为:具有大量集合,值越多,花费的时间就越长(我通过将所有值限制为0、1、2进行了测试)。 ??? ???

I can't show all parts of the code (too big), but some parts if needed. 我不能显示代码的所有部分(太大),但是如果需要的话,可以显示一些部分。

Thanks! 谢谢!

Your use case is not suited for symfony forms. 您的用例不适用于symfony形式。 Simple as that. 就那么简单。

Generete the inputs by hand, submit every collection entry via ajax, etc. 手工生成输入,通过ajax提交每个收集条目,等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM