-
-
Notifications
You must be signed in to change notification settings - Fork 437
Description
initial issue symfony/symfony#62766
I have a non-nullable title field on Book entity, on an edit form. i tried to clear the title field value and submit the form. it raised an error (http code 500). the expected output is validator error message should be appear (http code 422)
all form, entity, and controller in the reproducer repository were created using maker-bundle
How to reproduce
https://github.com/IndraGunawan/symfony-validator-reproducer
git clone [email protected]:IndraGunawan/symfony-validator-reproducer.git
cd symfony-validator-reproducer
symfony serve
head over to http://127.0.0.1:8000/new and directly click the submit button. This value should not be blank. error will be shown
head over to http://127.0.0.1:8000/edit and clear title field and click the submit button. InvalidTypeException will be raised, Expected argument of type "string", "null" given at property path "title".
TypeError
App\Entity\Book::setTitle(): Argument #1 ($title) must be of type string, null given, called in .../validator-issue-reproducer/vendor/symfony/property-access/PropertyAccessor.php on line 532
MakerBundle generates the setter for non-nullable field, does not allow null on the argument, do we need to update the generator to allow null even for non-nullable field?