title: Create form based on EntityType with option to add quantity
body: <p>I'm trying to setup a Symfony form that will allow a user to select a number of elements adding the wished quantity. I would like to be able to have a <code>FormType</code> which would be somewhere between an <code>EntityType</code> and the <code>IntegerType</code>. Meaning I need to have a list of elements based on a <code>query_builder</code> to select only part of my products, but I don't just want to be able to select the product but say how many I want of a given number of products.</p>
  
  <p>I've been able to create a form based on the options I send. For each product in my array I add an <code>IntegerType</code> field to my form using the builder. This allows me to show a list of products and ask the client the number of elements he wants.</p>
  
  <p>Now the problem I have is adding detailed data from the product in the list as I don't know the forms field names I can't interact with the label. If I could add something allowing me to say that the <code>'label'</code> could show as raw html, I could concatenate the wished data in the label.</p>
  
  <p>Here is my current form:</p>
  
  <pre class="lang-php prettyprint-override"><code>class OfferRequestStepMultipleHardwareType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          // instead of haveing set fields I create them based on the $option['step']-&gt;getProducts() data
          foreach ($options['step']-&gt;getProducts() as $product){
              $builder-&gt;add($product-&gt;getId().'-qty', IntegerType::class, [
                  'mapped' =&gt; false,
                  'attr' =&gt; [
                      'value' =&gt; 0,
                      'class' =&gt; 'longlist',
                      'min' =&gt; 0
                  ],
                  'row_attr' =&gt; [
                      'class' =&gt; 'longlist'
                  ],
                  'label' =&gt; $product-&gt;getNumber() // ideally I would do some thing like '&lt;div&gt;'.$product-&gt;getNumber().'&lt;/div&gt;&lt;div&gt;'.$product-&gt;getDescription().'&lt;/div&gt;' and then show it as raw in the form template
              ]);
          }
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; OfferRequest::class,
              'step' =&gt; StepHardware::class,
          ]);
      }
  }
  </code></pre>
  
  <p>The problem is this generates code a bit like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="offer_request_step_multiple_hardware"&gt;
    &lt;div class="longlist"&gt;&lt;label for="offer_request_step_multiple_hardware_27-qty" class="required"&gt;Product 1&lt;/label&gt;&lt;input type="number" id="offer_request_step_multiple_hardware_27-qty" name="offer_request_step_multiple_hardware[27-qty]" required="required" value="0" class="longlist"
        min="0"&gt;&lt;/div&gt;
    &lt;div class="longlist"&gt;&lt;label for="offer_request_step_multiple_hardware_28-qty" class="required"&gt;Product 2&lt;/label&gt;&lt;input type="number" id="offer_request_step_multiple_hardware_28-qty" name="offer_request_step_multiple_hardware[28-qty]" required="required" value="0" class="longlist"
        min="0"&gt;&lt;/div&gt;
    &lt;div class="longlist"&gt;&lt;label for="offer_request_step_multiple_hardware_29-qty" class="required"&gt;Product 3&lt;/label&gt;&lt;input type="number" id="offer_request_step_multiple_hardware_29-qty" name="offer_request_step_multiple_hardware[29-qty]" required="required" value="0" class="longlist"
        min="0"&gt;&lt;/div&gt;
    &lt;div class="longlist"&gt;&lt;label for="offer_request_step_multiple_hardware_30-qty" class="required"&gt;Product 4&lt;/label&gt;&lt;input type="number" id="offer_request_step_multiple_hardware_30-qty" name="offer_request_step_multiple_hardware[30-qty]" required="required" value="0" class="longlist"
        min="0"&gt;&lt;/div&gt;&lt;input type="hidden" id="offer_request_step_multiple_hardware__token" name="offer_request_step_multiple_hardware[_token]" value="PZaPfxKNSV-TjftRgjAw1K8XCUr7Dvkrp57kWTMBJ64"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I've also tried to create a form theming in the template to change the way the Integer widget show with this:</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% form_theme form _self %}
  
  {% block question %}
      &lt;h1&gt;{{ offer.lastStep.Question }}&lt;/h1&gt;
  {% endblock %}
  
  {% block integer_widget %}
      &lt;div class="name_row"&gt;
          {{ form_label(form)|raw }}
          {{ form_errors(form) }}
          {{ form_widget(form) }}
          {{ form_help(form) }}
      &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>Without any success as when I concatenate and try to add the filter "raw" to it, the code is still changed autoescaped. The problem is then I've found information on how to set a specific label for a specific field of a form, but again I generate the form on the go and have no way of knowing the field names (like described <a href="https://symfony.com/doc/2.6/cookbook/form/form_customization.html#how-to-customize-an-individual-field" rel="nofollow noreferrer">here</a>). Any suggestions on how to have this work?</p>
  
  <p>Ideally I would like to be able to create a FormType based on the EntityType which would allow to add an Integer instead of selecting the Entity elements...</p>
  
  <p>Any help would be nice!</p>