Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullable detection #6276

Open
wants to merge 2 commits into
base: 4.x
Choose a base branch
from
Open

Conversation

DrWarpMan
Copy link

@DrWarpMan DrWarpMan commented Apr 22, 2024

In Symfony production environment, since Doctrine 3.x, cached values for 'nullable' property can be either null, false or true. In Doctrine 2.x, it's only false or true. When Doctrine returns null for the nullable property, the required option for the field is set to false.

While in fact, Doctrine considers nullable => null as nullable => false, thus the field should be required.

To reproduce:

  • create an entity, with a field that has 'nullable' property set to false
  • create an admin controller for the entity (make sure to NOT set setRequired(true) explicitly)
  • try to create a new record in the dashboard, you will see that the field is optional

References:
Doctrine 3.x $nullable
How Doctrine determines nullable

In Symfony production environment, since Doctrine 3.x, values for 'nullable' property can be either null, false or true. In Doctrine 2.x, it was only false or true. When Doctrine returned 'null' for the nullable property, the required option for the field was set to false.

While in fact, Doctrine considers 'nullable => null' as 'nullable => false', thus should make the field required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants