{"id":879,"date":"2015-01-07T13:54:22","date_gmt":"2015-01-07T13:54:22","guid":{"rendered":"https:\/\/intelligentbee.com\/blog\/?p=879"},"modified":"2024-02-13T14:24:11","modified_gmt":"2024-02-13T14:24:11","slug":"symfony2-how-to-check-if-a-form-field-has-errors-in-twig","status":"publish","type":"post","link":"https:\/\/intelligentbee.com\/blog\/symfony2-how-to-check-if-a-form-field-has-errors-in-twig\/","title":{"rendered":"Symfony2: How to Check If a Form Field Has Errors in Twig"},"content":{"rendered":"<p>Sometimes you need to check if a field or even the entire form has errors before rendering them (e.g. when adding an <em>errors<\/em> container).\u00a0Here&#8217;s the code snippet that allows you to check for the <em>errors<\/em> form variable:<\/p>\n<pre class=\"lang:xhtml decode:true\">{% if form.vars.errors or form.fieldName.vars.errors %}\r\n...\r\n{% endif %}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need to check if a field or even the entire form has errors before rendering them (e.g. when [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"yst_prominent_words":[1369],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts\/879"}],"collection":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/comments?post=879"}],"version-history":[{"count":2,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts\/879\/revisions"}],"predecessor-version":[{"id":132713,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts\/879\/revisions\/132713"}],"wp:attachment":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/media?parent=879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/categories?post=879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/tags?post=879"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}