Sunday 15 June 2014

forms - How to acess Symfony 2 formview.valid variable in twig template -


itemprop = "text">

I use a value Have tried, but the method "valid" does not exist for

object "symphony \ component \ form \ formview"

Generate code here This error

  {% if form.valid == incorrect%} & lt; P class = "error" & gt; There is an error in the form Please correct. & Lt; / P & gt; {% Endif%}   

So my question is: is it already available variable or do we have to set it explicitly in the controller, or am I doing something wrong?

Thanks in advance.

The method isValid () is from the form class and not from the FormView, which is the one on the template Going when you have $ form-> on your controller. CreateView () return.

, you can check the validity of a form with the following:

  {% if form.vars.valid == false%} & lt; P class = "error" & gt; There is an error in the form Please correct. & Lt; / P & gt; {% Endif%}    

No comments:

Post a Comment