简体   繁体   English

Symfony中的树枝模板中的表单函数的堆栈跟踪

[英]Stack trace of form function inside twig template in Symfony

I have a problem that a variable gets rounded up to 3 decimals after the form function is run on the view object. 我有一个问题,就是在视图对象上运行表单函数后,变量会四舍五入到小数点后3位。 Literally before form: 1.222666 after form(when rendered) 1.223 从字面上看:形成后为1.222666(渲染时)1.223
So basically I need to know what else is happening inside of form function to locate the code that does this rounding up, I was thinking of doing stack trace of it. 因此,基本上我需要知道form函数内部还有什么变化,以找到进行此取整的代码,我当时正在考虑对其进行堆栈跟踪。 But how can I achieve that? 但是我该如何实现呢?
Advice on any other way to find out what is happening inside of form function is more than welcome. 欢迎以其他任何方式了解表单功能内部发生的情况的建议。 Symfony used is 2.6.8 使用的Symfony是2.6.8

EDIT: To make things more clear. 编辑:使事情更清楚。
The view in question is built inside of controller, when going through the steps of it there is no sign of any rounding or number format function. 有问题的视图内置在控制器内部,当执行其步骤时,没有任何舍入或数字格式功能的迹象。 By doing dump() on every individual step I have found that only after rendering this change happens. 通过在每个单独的步骤上执行dump(),我发现只有在呈现此更改之后才会发生。 However in twig file there is only 但是在树枝文件中只有

{{ form(productViewObject) }}

What I want to do is stack trace on all the actions happening inside of form, so I can locate the piece of code that does the rounding. 我想做的是在窗体内发生的所有动作上进行堆栈跟踪,因此我可以找到进行舍入的代码段。 I am not deeply familiar with Symfony but it seems that there is some kind of event or hook, something that is connected to this form function and performs the change. 我对Symfony并不很熟悉,但是似乎存在某种事件或挂钩,这些事件或挂钩与该form函数关联并执行更改。 That is what I want to do. 那就是我想做的。

You have to read documentation twig round: 您必须阅读树枝 文档

{{ 42.55|round }}
{# outputs 43 #}

{{ 42.55|round(1, 'floor') }}
{# outputs 42.5 #}

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

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