title: Set url parameter to entity - Symfony
body: <p>I have overridden the FOSUserbundle registration controller in Symfony. I am passing a parameter to url for registration and I wanted to set that parameter in my user entity. However I could pass the parameter and also get the parameter in the controller. But couldn't set that value to entity.</p>
  
  <p>Controller:</p>
  
  <pre><code>public function registerAction(Request $request)
  {
      $user = $userManager-&gt;createUser();
      $user-&gt;setEnabled(true);      
  
      $event = new GetResponseUserEvent($user, $request);
      $dispatcher-&gt;dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
  
       //Getting parameter
       $surveyID = $request-&gt;query-&gt;get('survey');
       //Setting parameter- Not working
       $user-&gt;setSurveyID($surveyID);
       //echo $surveyID;
  
      if (null !== $event-&gt;getResponse()) {
          return $event-&gt;getResponse();
      }
  
  
      $form = $formFactory-&gt;createForm();
      $form-&gt;setData($user);
  
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isSubmitted()) {
          if ($form-&gt;isValid()) {
              $event = new FormEvent($form, $request);
              $dispatcher-&gt;dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
  
              $userManager-&gt;updateUser($user);
  
              if (null === $response = $event-&gt;getResponse()) {
                  $url = $this-&gt;generateUrl('fos_user_registration_confirmed');
                  $response = new RedirectResponse($url);
              }
  
              $dispatcher-&gt;dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
  
              return $response;
          }
  
          $event = new FormEvent($form, $request);
          $dispatcher-&gt;dispatch(FOSUserEvents::REGISTRATION_FAILURE, $event);
  
          if (null !== $response = $event-&gt;getResponse()) {
              return $response;
          }
      }
  
      return $this-&gt;render('@FOSUser/Registration/register.html.twig', array(
          'form' =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>
  
  <p><code>$user-&gt;setSurveyID($surveyID)</code> is not working, but it works with <code>$user-&gt;setSurveyID('324324')</code></p>
  
  <p>Entity: User.php</p>
  
  <pre><code>/**
   * @ORM\Column(type="integer", nullable=true)
   */
  private $surveyID;
  
    /**
   * @return mixed
   */
  public function getSurveyID()
  {
      return $this-&gt;surveyID;
  }
  
  /**
   * @param mixed $surveyID
   */
  public function setSurveyID($surveyID = null)
  {
      $this-&gt;surveyID = $surveyID;
  }
  </code></pre>
  
  <p>What should I do to get that? Thanks!</p>
  
  <p>EDIT:</p>
  
  <pre><code>&lt;form name="fos_user_registration_form" method="post" action="/register" class="fos_user_registration_register"&gt;
  
  &lt;div id="fos_user_registration_form"&gt;&lt;div class="form-group"&gt;&lt;label class="control-label required" for="fos_user_registration_form_firstname"&gt;First Name *&lt;/label&gt;&lt;input type="text" id="fos_user_registration_form_firstname" name="fos_user_registration_form[firstname]" required="required" class="form-control" value="aasda"&gt;&lt;/div&gt;&lt;div class="form-group"&gt;&lt;label class="control-label required" for="fos_user_registration_form_lastname"&gt;Last Name *&lt;/label&gt;&lt;input type="text" id="fos_user_registration_form_lastname" name="fos_user_registration_form[lastname]" required="required" class="form-control" value="asd"&gt;&lt;/div&gt;&lt;div class="form-group"&gt;&lt;label class="control-label required" for="fos_user_registration_form_username"&gt;Username *&lt;/label&gt;&lt;input type="text" id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" class="form-control" value="asd"&gt;&lt;/div&gt;&lt;div class="form-group"&gt;&lt;label class="control-label required"&gt;Sex *&lt;/label&gt;&lt;div id="fos_user_registration_form_sex"&gt;&lt;div class="radio"&gt;                                                                                &lt;label class="required"&gt;&lt;input type="radio" id="fos_user_registration_form_sex_0" name="fos_user_registration_form[sex]" required="required" value="M"&gt; Male&lt;/label&gt;
  &lt;/div&gt;&lt;div class="radio"&gt;                                                                                &lt;label class="required"&gt;&lt;input type="radio" id="fos_user_registration_form_sex_1" name="fos_user_registration_form[sex]" required="required" value="F" checked="checked"&gt; Female&lt;/label&gt;
  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="form-group has-error"&gt;&lt;label class="control-label required" for="fos_user_registration_form_email"&gt;Email *&lt;/label&gt;&lt;input type="email" id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required" class="form-control" value="a.rafa@gci-brandlab.de"&gt;&lt;span class="help-block"&gt;    &lt;ul class="list-unstyled"&gt;&lt;li&gt;&lt;span class="glyphicon glyphicon-exclamation-sign"&gt;&lt;/span&gt; fos_user.email.already_used&lt;/li&gt;&lt;/ul&gt;
  &lt;/span&gt;&lt;/div&gt;&lt;input type="hidden" id="fos_user_registration_form_plainPassword" name="fos_user_registration_form[plainPassword]" value="Kjk5XsachYkA"&gt;&lt;input type="hidden" id="fos_user_registration_form_survey_id" name="fos_user_registration_form[survey_id]" value="12323"&gt;&lt;div class="form-group"&gt;&lt;label class="control-label" for="fos_user_registration_form_city"&gt;City&lt;/label&gt;&lt;input type="text" id="fos_user_registration_form_city" name="fos_user_registration_form[city]" class="form-control"&gt;&lt;/div&gt;&lt;div class="form-group"&gt;&lt;label class="control-label" for="fos_user_registration_form_zip_code"&gt;Zip Code&lt;/label&gt;&lt;input type="text" id="fos_user_registration_form_zip_code" name="fos_user_registration_form[zip_code]" class="form-control"&gt;&lt;/div&gt;&lt;div class="form-group"&gt;&lt;label class="control-label" for="fos_user_registration_form_age"&gt;Age&lt;/label&gt;&lt;input type="number" id="fos_user_registration_form_age" name="fos_user_registration_form[age]" class="form-control"&gt;&lt;/div&gt;&lt;div class="form-group"&gt;&lt;div class="checkbox"&gt;                                                            &lt;label class="required"&gt;&lt;input type="checkbox" id="fos_user_registration_form_privacy" name="fos_user_registration_form[privacy]" required="required" value="1" checked="checked"&gt; Accept data privacy&lt;/label&gt;
  &lt;/div&gt;&lt;/div&gt;&lt;input type="hidden" id="fos_user_registration_form__token" name="fos_user_registration_form[_token]" value="IXsOFEj4S-9oYxUcGK53BrG0CSn-EyRbYkXuC74H1Ic"&gt;&lt;/div&gt;
  </code></pre>
  
  
      
  
  
  <p></p>