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 7176849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:35:31+00:00 2026-05-28T16:35:31+00:00

I have a Team to which I would like to add players (objects of

  • 0

I have a Team to which I would like to add players (objects of Player). I’ve set up the form “type” classes correctly. Here’s the relevant part of my view:

{% for index, player in form.players %}
    <div id="template" data-prototype="{{ form_widget(form.players.get('prototype')) | e }}">
        <span class="title">{{ index }}</span>
        {{ form_row(player.name) }}
    </div>
{% endfor %}

My problem is that data-prototype attribute doesn’t include the span tag; it only contains the output of {{ form_row(player.name) }}. Is there a way to include the whole content of div#template in the data-prototype attribute?

  • 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-28T16:35:32+00:00Added an answer on May 28, 2026 at 4:35 pm

    This was bugging me too. I customized a field type and even made simple form types with a reduced fieldset (for more complex objects), but it just didn’t feel right. I’ve come up with a solution that should do the trick 🙂

    First – I think your <div id="team" data-prototype="..."> should be outside your loop.

    Next, your prototype is just a form view object, so if you pass it to a template you can render fields by hand and customize the output. Note: autoescape has no effect on included content, so use ‘filter escape’.

    <div id="playerFields" data-prototype="{% filter escape %}{% include 'AcmeTeamBundle:Team:prototypePlayer.html.twig' with {'form': form.players.get('prototype')} %}{% endfilter %}">
    

    Then in your prototypePlayer.html.twig, just render each field as you normally would in a form view.

    <div>
        <span class="title">{{ form_label(form.name) }}</span>
        {{ form_row(form.name) }}
        <span class="age">{{ form_label(form.age) }}</span>
        {{ form_row(form.age) }}
        {# render whatever else you like from your Form/PlayerType class... #}
    <div>
    

    My template has a different data structure to your question, but it should help 🙂

    Cheers,

    Chris


    Deprecation Warning:

    As of Symfony 2.1, .get() is deprecated and the above will not work. Replace form.players.get('prototype') with form.players.vars.prototype to fix this in later versions of Symfony.

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

Sidebar

Related Questions

Team, I would like to know how to set up appstore for its enterprise
i have this GUI screen shots from the design team which i needs to
At the team with which I work, we have an old codebase using PHP's
In our team we have a database project in visual Studio 2008 which is
I have a SVN repository which is currently structured like so: /versions /1.0.0 /1.0.1
So I have a form that lets a user create a new team. Our
I would like to upgrade my team from VS2005 to VS2008 without touching the
Our SEO team would like to open up our main dynamic search results page
I have a Team table /entity with a parentId which is an id that
I have a form on my Java application which basically is to provide the

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.