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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:31:22+00:00 2026-06-12T02:31:22+00:00

I have a form with a collection type field, rendered like that: <div id=beneficiosTab

  • 0

I have a form with a collection type field, rendered like that:

<div id="beneficiosTab" class="opcional">
    Beneficios
    <ul class="beneficios" data-prototype="{{ form_widget(formAtendimento.beneficios.get('prototype')) | e }}">
        {% for beneficio in formAtendimento.beneficios %}
            <li>{{ form_row(beneficio.coTipoBeneficio) }}</li>
            <li>{{ form_row(beneficio.vrValor) }}</li>
            <li>{{ form_row(beneficio.boConcedido) }}</li>
        {% endfor %}
        <li><a href="#" id="addBeneficio">Add Beneficio</a></li>
    </ul>
</div>
<div style="clear:both"></div>
{{ form_rest(formAtendimento) }}

The form’s entity can have multiple items of the collection, or none.

When the entity has items of the collection, it works fine, but when it has none, the “for” in the twig doesn’t happen, and a “Beneficios” div is generated in form_rest.

Any way I can prevent that? Thanks in advance.

  • 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-06-12T02:31:23+00:00Added an answer on June 12, 2026 at 2:31 am

    This seems like a bug in the form rendering. I managed to disable the extra form rendering in the form_rest function, by adding this code just after rendering the collection elements:

    {% do form.uploads.setRendered() %}
    

    Where “uploads” is my collection field type.
    This doesn’t seem like best practice to me though.

    So the whole rendering looks like this:

     <div id="uploads" data-prototype="{{ form_widget(form.uploads.vars.prototype)|e }}">
            {% for upload in form.uploads %}
                {{ form_widget(upload) }}
            {% endfor %}
      </div>
      {% do form.uploads.setRendered() %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection where all form data is stored, each form with a
I have the following structure in a form: <div class='full'> <div class='half'> <label>Book</label> <select
I have a form using this class type: class DespesasContainerType extends AbstractType { public
I have two models, Item and Bid class Item include Mongoid::Document field :name, type:
I have two Doctrine entities that have a one-to-many relationship, like this: License class
I have a form where users can modify a collection of objects using a
I have a collection of the form: map<key, list<object> > I only ever insert
I have a collection of PHP classes that can be instantiated traditionally using constructors.
Let's say i have such structure public class Form { #region Public Properties public
I have a java form in which i have declared different variables of type

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.