Fix #207 set pet owner when for has an error

This commit is contained in:
Kristof Neirynck 2016-12-01 19:28:47 +01:00 committed by Dave Syer
parent ca2a66500f
commit 61be1bac41

View file

@ -103,6 +103,7 @@ class PetController {
@RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.POST) @RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.POST)
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) { public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) {
if (result.hasErrors()) { if (result.hasErrors()) {
pet.setOwner(owner);
model.put("pet", pet); model.put("pet", pet);
return VIEWS_PETS_CREATE_OR_UPDATE_FORM; return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
} else { } else {