get entity obj from form view in twig template


form.get('value')
is deprecated since symfony 2.1. Copy from Symfony\Component\Form\FormView :
/*
 * @deprecated Deprecated since version 2.1, to be removed in 2.3. Access
 *             the public property {@link vars} instead.
 */
public function get($name, $default = null) ....
so, I guess
form.vars.value.youMethod()
And if you get 
{{ form.vars.value }}
is NULL.
If you have form.element (not the form object itself) object, for example if you are overriding a form_row template that has passed the form.row object, you can get the Entity like this:
{{ form.getParent().vars.value.MyEntityMethod }}

评论

热门帖子