Character fields of type "Symbony" report "This is an invalid value" when submitting an invalid option. How can I change this?

I noticed that when using the Symfony 2.3 selection box type, if I try to send an invalid parameter (manually changing the parameter value), symfony reports a form error in this field that says: "This value is equally invalid."

However, I do not see the possibility of changing this message in a class such as a selection field. I also have no validation restrictions for this field.

Where does this error message come from and how to change it?

+7
symfony
source share
2 answers

The "Invalid value" clause is the default error message that results in a form field conversion failure. This error message is associated with each field in the event of a data converter failure (in your case, it seems that you are trying to send an invalid selection value). If you want to override it, you can use options like invalid_message and invalid_message_parameters .

I cannot find the official documentation of this property right now, but you can take a look at it in more detail: link

+11
source share

The message is based on a selection restriction, not a class type of a selection field.

http://symfony.com/doc/current/reference/constraints/Choice.html

The message parameter can be overridden by your own message.

+2
source share

All Articles