Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6837479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:28:56+00:00 2026-05-26T23:28:56+00:00

This § of the Symfony2 documentation shows an awesome technique for customizing an individual

  • 0

This § of the Symfony2 documentation shows an awesome technique for customizing an individual field. I’m using it a lot but there is one particular Type for which I’m having a hard time doing the customization : the CollectionType() Customizing the collection itself is quite easy, you can do something like this:

{% block _mynamespace_mybundle_mytype_mycollectionfield_row %}
{% if prototype is defined %}
    {% set attr = attr|merge({'data-prototype': form_widget(prototype) }) %}
{% endif %}
{% spaceless %}
    <ul {{ block('widget_container_attributes') }}>
        {% spaceless %}
            {{ form_errors(form) }}
            {% for child in form %}
            <li>
              {{form_widget(child)}}
            </li>
            {% endfor %}
        {% endspaceless %}
        {{ form_rest(form) }}
    </ul>
{% endspaceless %}
{% endblock %}

But how can you customize each element of the collection ? And how can you customize the data-prototype using Twig (the data-prototype is a special attribute used to add new items with js)?

I tried doing something like this (for the data-prototype):

{% block _mynamespace_mybundle_mytype_mycollectionfield_$$name$$_row %}
customization ok!
{% endblock %}

But I get errors, because I don’t know how to escape the $

Regarding the items, I tried many things:

{% block _mynamespace_mybundle_mytype_mycollectionfield_item_subfield_row %}
customization ok!
{% endblock %}

{% block _mynamespace_mybundle_mytype_mycollectionfield_element_subfield_row %}
customization ok!
{% endblock %}

None of them work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:28:57+00:00Added an answer on May 26, 2026 at 11:28 pm

    I asked the question in symfony’s bug tracker, and it seems there is no solution, but a good workaround is creating a custom type for each subfield you want to customize. See this issue

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using symfony2 I am following this documentation to create and use a service for
How to have multiple firewalls with symfony2? This is mentioned in the documentation but
I followed this tutorial (official documentation for symfony 1.4). The project is created but
I'm using Symfony 1.4 with Doctrine. Sorry if this is a silly question but
I'm using Symfony2 Framework, and this is what I want to do: I want
so im reading the internals documentation for symfony2 http://symfony.com/doc/current/book/internals.html and i dont understand this
I can't seem to find any documentation on Symfony2 forms when using Propel ORM.
I'm trying to follow this documentation on Symfony : http://symfony.com/doc/current/book/forms.html ok so here is
My Symfony2 application replaces my PHPSESSID cookie when it logs me in. Is this
When I update my Symfony2 project I always have to do this: root@xxx:/var/www/project# php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.