0

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

1
  • Do you have a return $values; statement at the end of your callback? Commented Mar 17, 2012 at 9:23

1 Answer 1

1

ok.. found the answer... need to use taintedValues within the call back validator.. before throwing the error..

public function validate_requester_id($validator, $values){
  ...
  $this->taintedValues['fieldname'] = NEW VALUE
  ... 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.