Symfony form.vars.data vs form.vars.value(Symfony form.vars.data 与 form.vars.value)
问题描述
A FormView object in Symfony contains several variables, that can be accessed via twig using the public vars
property.
Two of those variables are value
and data
.
So, supposing that we have our form
variable in twig, we can access them using form.vars.data
and form.vars.value
.
The documentation is clear about the meaning of those properties:
value: The value that will be used when rendering (commonly the value HTML attribute).
data: The normalized data of the type.
but when I use {{ dump(form.vars) }}
and compare form.vars.value
and form.vars.data
they look like identical. Why? What's the correct meaning and proper usage of those two properties?
Take for example a DateType field.
Here, value
would be something like the string 2016-06-10
.
data
on the other hand would be a corresponding DateTime
-Object.
When using Text fields, you will not see any difference because in both cases there will be just a string.
这篇关于Symfony form.vars.data 与 form.vars.value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Symfony form.vars.data 与 form.vars.value


- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01