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

Model forms with a non-nullable select column with default not being validated for blank value #170

Open
pytrumpeter opened this issue Mar 3, 2022 · 1 comment

Comments

@pytrumpeter
Copy link

I created a form which contains a select field, based on a column that is both non-nullable and has a default specified on the entity. When the field is rendered by the default form rendering, it contains a blank value (by design) but when that blank value is selected and the form submitted, there is no validation happening, and an integrity error results: null value in column violates not-null constraint

The workaround is to specify the SelectField explicitly and include validators=[InputRequired()]

@guruofgentoo
Copy link
Member

I think we'll need more details here or an example. If I'm understanding correctly, a blank value option is included in the list by design, and the model has a default. In that case, the model form generator should be setting up the field without an input requirement, because of the entity default.

When the form is submitted, the entity default value should kick in and apply to the record.

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

No branches or pull requests

2 participants