简体   繁体   中英

How to customize collection element in symfony2 forms

I have a simple form related to a user in which i'm adding a collection of phone numbers (another form).

I can get it working with javascript but i want to customize the rendering of each phone input.

The same thing is working with a simple field by doing this :

{% block _elementId_widget %}
    {{ block('form_widget_simple') }}
    <input type="button" class="btn" id="btnInvertNames" value="{{ "form.invertNames"|trans }}" />
{% endblock %}

To add a button after the widget, but not working with collections..

A solution i found is to write a new "Form Type" and to customize its template :

Look here for documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM