I've created my own data transformer, as explained in the dedicated cookbook, here is my reverse transformation:
public function reverseTransform($val)
{
// ...
// My logic here
// ...
// If $val is not valid
throw new TransformationFailedException(
'My custom error message'
);
}
The question is: how do I get the "custom error message" thrown? I would like to display it as the error message of my form field. How do I do that?
Thanks!
Sort answer is: You don't. The transformers job is to, well, transform and not to do error checking.
Add a constraint to the field which will check the transformed value and take care of error messaging.