Symfony form.vars.data vs form.vars.value

Symfony's FormView object contains several variables that can be accessed through a branch using a public property vars.

Two of these variables are: valueand data.

So, suppose we have our variable formin a branch, we can access it with form.vars.dataand form.vars.value.

The documentation is clear about the meaning of these properties:

  • value : the value that will be used when rendering (usually the value of the HTML attribute).

  • data : normalized type data.

but when I use {{ dump(form.vars) }}and compare form.vars.valueand form.vars.data, they look the same. What for? What is the correct meaning and proper use of these two properties?

+4
source share
1 answer

Take, for example, the DateType field.

Here valuewill be a bit of a line 2016-06-10. data, on the other hand, would be the corresponding DateTime-Object.

When using text fields, you will not see any difference, because in both cases there will be only a string.

+8
source

All Articles