I've been struggling with this for a few days and have not being able to come up with the answer. I need to change a form value after an initial submit. The value will be retrieved from an external web service using one of the values submitted. The value used to search is a person id which is validated with a web service to make sure it is a valid id. With this info the web service returns the full name and I need to display it back in the form so that the user is sure that it is the person expected, this fullname is also saved with the other values.
I already saw this approach and I am able to change form values from the action with this: http://www.thenameiskhan.com/binding-changed-form-values-symfony
$values = $request->getParameter($form->getName());
$values['yourdate'] = NEW MODIFIED DATE VALUE;
$form->bind($values, $request->getFiles($form->getName()));
but I am trying to accomplish this from the form class in sf ValidatorCallback function which is validating the id provided and retrieving the fullname..
public function validate_requester_id($validator, $values){
.....
$webserviceanswer = CALLWEBSERVICE($values['person_id'])
if ($webserviceanswer['code'] == VALID){
$values['person_fullname'] = $webserviceanswer['fullname'];
}
if( notvalid or first submit){
...// so as to display fullname to user.....
throw new sfValidatorError($validator, 'blablabla')
...
}
}
but when back in the form the value assigned to $values['person_fullname'] is not changed
Later I will also update the fullname value through ajax calling the webservice after the onchange event of the requester_id.. but want to have the fallback nonajax version working first.
thanks.
ivan
return $values;statement at the end of your callback?