title: How to fix the error "Neither the property nor one of the methods... exist and have public access in class..." with Symfony form
body: <p>I am trying to build a form with Symfony. From the moment I added the submit button by adding this {{form_widget(userform.Subscription)}}, I am facing with this error message :</p>
  <p>Neither the property &quot;Subscription&quot; nor one of the methods &quot;Subscription()&quot;, &quot;getSubscription()&quot;/&quot;isSubscription()&quot;/&quot;hasSubscription()&quot; or &quot;__call()&quot; exist and have public access in class &quot;Symfony\Component\Form\FormView&quot;.</p>
  <p>If you have an idea of what is happening, thank you very much for your help.</p>
  <p>Here is my code :</p>
  <p><strong>register.html.twig</strong></p>
  <pre><code>{% extends 'base.html.twig' %}
  
  {% block title %}Incris-toi !{% endblock %}
  
  {% block main %}
  
  {{form_start(userform)}}
  
      &lt;div class=&quot;form container&quot;&gt;
  
          &lt;div class=&quot;formpage&quot;&gt;
              &lt;div class=&quot;form-floating mb-3&quot;&gt;
                  {{form_widget(userform.occupation, {'attr' : {'placeholder' : 'Quelle est ton occupation (ton métier, tes études…) ?', 'class' : 'form-control'}})}}
                  {{form_label(userform.occupation, 'Quelle est ton occupation (ton métier, tes études…) ?', {'label_attr' : {'class' : 'label'}})}}
              &lt;/div&gt;
              &lt;div class=&quot;mb-3&quot;&gt;
                  &lt;p&gt;De quel pays es-tu originaire ?&lt;/p&gt;
                  {{form_widget(userform.nationality)}}
              &lt;/div&gt;
              &lt;div class=&quot;mb-3&quot;&gt;
                  &lt;p&gt;Quelle est ta langue maternelle ?&lt;/p&gt;
                  {{form_widget(userform.nativelanguage)}}
              &lt;/div&gt;
              &lt;div class=&quot;optional mb-3&quot;&gt;
                  &lt;p&gt;Quelle langue souhaites-tu pratiquer ?&lt;/p&gt;
                  {{form_widget(userform.wishedlanguages, {'attr' : {'class' : 'form-control'}})}}
              &lt;/div&gt;
              &lt;div class=&quot;d-flex&quot;&gt;
                  &lt;button type=&quot;button&quot; class=&quot;prev btn btn-lg btn-outline-secondary mt-4 d-flex align-items-center me-auto&quot;&gt;&amp;lt;&lt;span class=&quot;previous&quot;&gt;Précédent&lt;/span&gt;&lt;/button&gt;
                  {{form_widget(userform.Subscription, {'attr' : {'class' : 'btn btn-lg btn-outline-primary mt-4 d-flex ms-auto'}})}}
              &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  
  {{form_end(userform)}}
  
  {% endblock %}
  </code></pre>
  <p><strong>UserType.php</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Form;
  
  use App\Entity\User;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\CallbackTransformer;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\CountryType;
  use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
  use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  use Symfony\Component\Form\Extension\Core\Type\LanguageType;
  use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  
  class UserType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options): void
      {
          $builder
              -&gt;add('gender', ChoiceType::class, [
                  'choices' =&gt; [
                      'Je suis ...' =&gt; '',
                      'un homme' =&gt; 'male',
                      'une femme' =&gt;'female',
                      'non-binaire' =&gt; 'non-binary'
                  ]
              ])
              -&gt;add('lastname')
              -&gt;add('firstname')
              -&gt;add('birthdate', BirthdayType::class, [
                  'placeholder' =&gt; [
                      'year' =&gt; 'Année', 'month' =&gt; 'Mois', 'day' =&gt; 'Jour',
                  ],
                  'choice_translation_domain' =&gt; true
              ])
              -&gt;add('occupation')
              -&gt;add('nationality', CountryType::class, [
                  'placeholder' =&gt; 'Je choisis un pays',
              ])
              -&gt;add('nativelanguage', LanguageType::class, [
                  'placeholder' =&gt; 'Je choisis ta langue maternelle',
              ])
              -&gt;add('wishedlanguages', LanguageType::class, [
                  'placeholder' =&gt; 'Je choisis une langue étrangère',
              ])
              -&gt;add('email')
              -&gt;add('password', PasswordType::class, [
                  'mapped' =&gt; false
              ])
              -&gt;add('password', RepeatedType::class, [
                  'type' =&gt; PasswordType::class,
                  'invalid_message' =&gt; 'Les deux mots de passe doivent être identiques.',
                  'options' =&gt; ['attr' =&gt; ['class' =&gt; 'password-field']],
                  'required' =&gt; true,
                  'first_options'  =&gt; ['label' =&gt; 'Password'],
                  'second_options' =&gt; ['label' =&gt; 'Repeat Password'],
              ])
              -&gt;add('roles', CheckboxType::class, [
                  'label' =&gt; 'Je m\'inscris uniquement en tant qu\'organisateur.',
                  'required' =&gt; false,
                  'compound' =&gt; true,
              ])
              -&gt;get('roles')
              -&gt;addModelTransformer(new CallbackTransformer(
                  function ($arrayAsBool) {
                  return in_array(&quot;ROLE_ADMIN&quot;, $arrayAsBool);
              },
                  function ($boolAsArray) {
                  return $boolAsArray ? [&quot;ROLE_ADMIN&quot;] : [&quot;ROLE_USER&quot;];
              }))
              -&gt;add('Subscription', SubmitType::class);
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver): void
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; User::class,
              'translation_domain' =&gt; 'forms'
          ]);
      }
  }
  </code></pre>