Skip to content

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

Open

Description

@pytrumpeter

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()]

Activity

  1. guruofgentoo commented on Dec 2, 2022

    @guruofgentoo
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions