title: Ignore Password when user updates profile with FOSUserBundle
body: <p>I am using FOSUserBundle and I am trying to create a page that allows a user to update their user profile. The problem I am facing is that my form does not require that the user reenter their password if they don't want to change/update their password. So when a user submits the form with an empty password the database will be updated with an empty string, and the user will not be able to log in.</p>
  
  <p>How can I get my form to ignore updating the password field if it is not set? Below is the code I am using.</p>
  
  <pre><code>$user = $this-&gt;get('security.context')-&gt;getToken()-&gt;getUser();
  
  //user form has email and repeating password fields    
  $userForm = $this-&gt;createForm(new UserFormType(), $user);
  
  if ($request-&gt;getMethod() == 'POST') {
     $userForm-&gt;bindRequest($request);
  
     if($userForm-&gt;isValid()){
        //this will be be empty string in the database if the user does not enter a password
        $user-&gt;setPlainPassword($userForm-&gt;getData()-&gt;getPassword());
        $em-&gt;flush();
     }
  }
  </code></pre>
  
  <p>I have tried a few things such as the following, but this is still empty because the bindRequest sets the empty password to the user</p>
  
  <pre><code>if($userForm-&gt;getData()-&gt;getPassword())
     $user-&gt;setPlainPassword($userForm-&gt;getData()-&gt;getPassword());
  </code></pre>
  
  <p>I have also tried, but this results in a similar situation and causes an unneeded query</p>
  
  <pre><code>if($userForm-&gt;getData()-&gt;getPassword())
     $user-&gt;setPlainPassword($userForm-&gt;getData()-&gt;getPassword());
  else
     $user-&gt;setPlainPassword($user-&gt;getPlainPassword());
  </code></pre>
  
  <p>Are there any elegant ways to handle this use case?</p>