Using this manual, I added dynamic field to my form. Now, how can I check existence of this field in my template?
{{ form_start(form) }}
  {{ form_errors(form) }}
  {% if ??? %}     <---------------------------
    {{ form_row(form.myDynamicField) }}
  {% endif %}
{{ form_end(form) }}
                What about,
{% if form.myDynamicField is defined %}
    {{ form_row(form.myDynamicField) }}
{% endif %}
You may also need to check if form.myDynamicField is not null.
I know this question is a few years old, but you could also make it a shorter ternary operator.
{{ form.myDynamicField is defined ? form_row(form.myDynamicField) : null }}
{{ form_start(form) }}
  {{ form_errors(form) }}
  {% if form.getChildren['myDynamicField'] is defined %}
    {{ form_row(form.myDynamicField) }}
  {% endif %}
{{ form_end(form) }}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With