3

So, what I need to do is to output current element's ID in each field_row. What I came to is overriding Symfony's default field_row block with the following code:

{% block field_row %}
{% spaceless %}
<div class="clearfix" id="{{ form.get('name') }}-row">
    {{ form_label(form) }}
    <div class="input"&gt;
        {{ form_widget(form) }}
    </div>
</div>
{% endspaceless %}
{% endblock field_row %}

However, the {{ form.get('name') }} construct seems pretty awkward to me and I'm sure there's a more civilised way of doing this. Anyone?

1 Answer 1

7

Do you mean the id generated by symfony? then it's just:

{{ id }}
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, thanks! That's it, turned out to be pretty obvious, although I couldn't find it in the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.