My simple data transformer transforms a number to an entity and vice-versa. It's pretty like the example in the official documentation.
The reverseTransform
method converts a number to an entity and when it fails it throws a TransformationFailedException
with a descriptive message:
public function reverseTransform($number)
{
if (!$number) {
return null;
}
$issue = $this->om
->getRepository('AcmeTaskBundle:Issue')
->findOneBy(array('number' => $number))
;
if (null === $issue) {
throw new TransformationFailedException(sprintf(
'An issue with number "%s" does not exist!',
$number
));
}
return $issue;
}
However the form field using the above transformer gets a generic error message "This value is not valid". Even changing the exception text (that I would expect to be used as validation message, but it's not...) doesn't change the error message.
How can I display the exception text instead of "This value is not valid"?