php - How do I render validation errors in controller through twig template -


how render validation errors in controller through twig template. not able access validation errors in controller.

i found way

$validator = $this->get('validator'); $errors = $validator->validate($entity); $content = $this->renderview('yourbundle:yourentity:template.html.twig',array('errors'=>$errors));  {% if errors %}     {% error in errors %}         <li>{{ error.message }}</li>     {% endfor %} {% endif %} 

how field name has error out here

$validator = $this->get('validator'); $errors = $validator->validate($entity); $content = $this->renderview('yourbundle:yourentity:template.html.twig',array('errors'=>$errors));  {% if errors %}     {% error in errors %}         <li>{{ error.message }}</li>         <li>{{ error.propertypath }}</li>     {% endfor %} {% endif %} 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -