Skip to content Skip to sidebar Skip to footer

Symfony/jquery Collection Of Objects

I have a web app in Symfony. When I have a collection of objects (A user has many addresses) I need to implement JavaScript/jQuery method to let the user add the number of addresse

Solution 1:

You can always customise your form rendering, at any level. Here, you need to customise it for a particular twig. This document is your reference. You can choose form_label and form_widget blocks to overwrite as per your need.

{% form_theme form _self %}

{% block form_label %}
    <divclass="col-lg-4 col-md-4 col-sm-6 col-xs-12>
        {{- parent() -}}
    </div>
{% endblock %}

{% block form_widget %}
    <div class="col-lg-4col-md-4col-sm-6col-xs-12>
        {{- parent() -}}
    </div>
{% endblock %}

In above code form is the Form variable in the twig.

If you want only your collection fields to have a different structure, save them in a separate twig and include in main twig. Then, customise the included twig only.

PS : Code not tested.

Hope this helps!

Post a Comment for "Symfony/jquery Collection Of Objects"