title: Ignore Required attribute when saving on edit page
body: <p>I have a model class that has a couple of required fields:</p>
  
  <pre><code>public class UserMetadata
  {
     [Required(ErrorMessage = "Please enter a name.")]
     public string Name { get; set; }
  
     [Required(ErrorMessage = "Please enter a password.")]
     public string Password { get; set; }
  }
  </code></pre>
  
  <p>On the create view, if I don't give a name and/or password, then the validation summary errors appears. All nice and good. For the edit view, I'm only displaying the 'Name' field - I don't to show the 'Password' field.</p>
  
  <p>When I save my changes on the edit page, the validation summary error appears saying that I must enter a password.</p>
  
  <p>How can I control the validation of the password field, so that for the edit view, it should not bother with it? Or, am I approaching this the wrong way? I still want the 'Name' field validation to work on the edit view.</p>
  
  <p>EDIT:</p>
  
  <p>For my MVC project, I'm using Entity Framework. Thus, I have a 'UserMetadata' class defined so that I can attached things like '[Required]' onto certain fields on the 'User' class (which is in the EDMX file).</p>
  
  <p>I should also explain that I'm using a view model eg 'UserEditViewModel' which has a property 'User' attached to it. So on my post:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(UserEditViewModel inputViewModel)
  {
  
      if(ModelState.IsValid) { inputViewModel.User blah.... }
  
  }
  </code></pre>
  
  <p>Think I rushed a bit when typing this question. Any other missing information you think is important, then please give me a shout.</p>
  
  <p>Cheers.
  Jas.</p>