Closed RomainSanchez closed 7 years ago
The issue was occuring both with AJAX and non-ajax since dd4695ee61464c252ca1ef61658787dfaae457d5, and was fixed with non-ajax in 05a128a94eaeb71421a9defef90b6049bb3c6167
Removing line 22 of https://github.com/sonata-project/SonataAdminBundle/blob/05a128a94eaeb71421a9defef90b6049bb3c6167/Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig#L22 fixes the issue, not sure it is the right fix though.
I think adding a check on value|length would be better
Environment
DEV
Sonata packages
Symfony packages
PHP version
Subject
When editing an object with a REQUIRED form field of type
sonata_type_model_autocomplete
and usingby_reference => false
the form can't be submitted as the autocomplete input from the select fromsonata_type_model_autocomplete
has the required attribute, hence html5 validation is failing even though the field is not empty. Ifby_reference
is not set to false it works correctly.Got the same results in different admins.
If the
by_reference
option is not supposed to be used with sonata_type_model_autocomplete shouldn't anUndefinedOptionsException
be thrown ?Here is the relevant part of the dump of the formMapper
and the rendering call graph