Skip to content

Non-nullable columns with a default value should be optional #47

Open
@smsearcy

Description

@smsearcy

While switching to wtforms-sqlalchemy from another library I ran into an issue that we have columns with nullable=False and default value, which should be able to post, but the generated form had added a required validator to those fields so validation failed.

Example of columns:

description = Column(Unicode(20), default="", nullable=False)
active = Column(Boolean, default=True, nullable=False)

Validation result from submitting form:
image

The expected result is that those fields should not have been required so that form processing would continue. Do you see any issues with setting columns with a default to Optional?

Edit: It seems that a checkbox should never be required, right?

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