Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony choice field type reports "This value is not valid" when submitting an invalid option. How do I change this?

I've noticed that when using the Symfony 2.3 choice field type, if I try to submit an invalid option (by manually changing the value of an option), symfony reports a form error on that field that says "This value is not valid".

However, I see no option to change this message in the choice field type class. I have not validation constraints set up for this field either.

Where is this error message coming from, and how do I change it?

like image 414
user3009816 Avatar asked Nov 19 '13 17:11

user3009816


1 Answers

The sentence "The value is not valid" is the default error message which results of a form field transformation failure. This error message is related to each field in case of a data transformer failed (in your case it seems you try to send an invalid choice value). If you want to override it, you can use the invalid_message & invalid_message_parameters form type options.

I can't find the official documentation of this property right now but you can take a look to this for more details: link

like image 141
egeloen Avatar answered Oct 05 '22 13:10

egeloen