You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One can't curently access the underlying data of choices. This should be possible though to make further calculations in the templates possible.
Assume that the choices are a set of objects with a getId() and a getName() method. Then the choice values can be configured to point to $object->getId() and the choice labels can be configured to point to $object->getName(). In the template, these values can be retrieved in the following way:
It is however not possible to access the $object instance itself. It would be desirable to make this possible, which can be done using the following approach:
add a "data" field to ChoiceView that contains the original choice, i.e. $object in our case
add a "form" field to ChoiceView that contains the form representing the choice (only relevant if expanded=true)
The template can then be handled in a more uniform manner (and more independent of expanded/collapsed). Furthermore, $object can be accessed.
Commits
-------
686bf6b [Form] Made original data of a form and choices accessible in templates
Discussion
----------
[Form] Made original data of a form and choices accessible in templates
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #4171
Todo: -
Now you can access the normalized data of a form in the template:
```
form.vars.data
```
You can also access the original data of a choice, for example the entities in an entity type:
```
choice.data
```
One can't curently access the underlying data of choices. This should be possible though to make further calculations in the templates possible.
Assume that the choices are a set of objects with a getId() and a getName() method. Then the choice values can be configured to point to $object->getId() and the choice labels can be configured to point to $object->getName(). In the template, these values can be retrieved in the following way:
It is however not possible to access the $object instance itself. It would be desirable to make this possible, which can be done using the following approach:
The template can then be handled in a more uniform manner (and more independent of expanded/collapsed). Furthermore, $object can be accessed.
The text was updated successfully, but these errors were encountered: