"should be equal to one of the allowed values" error on choice field
I'm using liform-react with LiformBundle. I have a form:
$builder->add('someField', EntityType::class, [
'label' => $this->getLabel($contact),
'required' => false,
'class' => 'Entity\SomeEntity',
]);
Object generated by liform:
properties: {
someField: {
enum: ["1", "2", "3"],
enum_titles: ["one", "two", "three"],
// ...
}
}
After selecting an option, ajv returns validation error
"should be equal to one of the allowed values"
https://github.com/epoberezkin/ajv/blob/1c702d639cbf1d97dd8d44822bcaac43b3c4dc6f/lib/dot/errors.def#L102
On backend there is no validation errors.
Hi, have you already found a solution? I'm encountering the same problem. Adding an empty string within both enum and enum_titles fixes the problem but also hides the placeholder :|
You can change the type to be one of either null or enum (note the quotes around "null"!):
properties: {
someField: {
oneOf: [
{ type: "null" },
{
type: "string",
enum: ["1", "2", "3"]
}
]
// ...
}}
see https://github.com/epoberezkin/ajv/issues/824