title: How to add classes to Symfony 4 "ChoiceType" item labels?
body: <p>I have here four radio buttons, and I want to add a css class to each label of the radio button. How can I do that? I have tried two ways but neither are working:</p>
  
  <p>Try 1: </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>        -&gt;add('background', ChoiceType::class, ['label'=&gt;'2. Dein Hintergrund: ', 
          //this adds class to the parent div
          'attr' =&gt; ['class' =&gt; 'label'],
          'choices'  =&gt; [
              1 =&gt; 1,
              2 =&gt; 2,
              3 =&gt; 3,
              4 =&gt; 4
          ], 'choice_value' =&gt; null,
          'expanded' =&gt; true,
          'multiple' =&gt; false,
          // this adds class to all radios/input elements
          'choice_attr' =&gt; function($choice, $key, $value){
              return ['class' =&gt; 'radio radio_'.($key)];
           },
           //this does NOT work, no error but it will not render a class to the label! Why?
           'label_attr' =&gt; function($choice, $key, $value){
              return ['class' =&gt; 'label'.($key)];
           },
          ])</code></pre>
  </div>
  </div>
  </p>
  
  <p>Try 2: </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 class="container"&gt;
     {{ form_label(form.background, {'attr': {'class': 'label'}}) }}
              {{ form_widget(form.background) }}
              &lt;button class="button_main"&gt;Übernehmen&lt;/button&gt;
          &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>With number 2 I get the following error: </p>
  
  <blockquote>
    <p>An exception has been thrown during the rendering of a template ("Notice: Array to string conversion").</p>
  </blockquote>
  
  <p>I have looked at this <a href="https://symfony.com/doc/current/reference/forms/types/choice.html#choice-attr" rel="nofollow noreferrer">documentation</a> many times but can't figure it out!</p>