wtforms-sqlalchemy icon indicating copy to clipboard operation
wtforms-sqlalchemy copied to clipboard

Columns with a default value should not be required

Open smsearcy opened this issue 1 year ago • 1 comments

If a column has a default value, then make the input field optional when generating a form object from a model.

This enables the defaults in the table definition to allow for empty string in a text field and an unchecked checkbox to be submitted.

Closes #47

smsearcy avatar May 10 '24 15:05 smsearcy

I just realized I did not test the scenario in which the default value of a boolean column is True. That might require some special handling for the checkboxes, unless WTForms already handles that somehow.

Edit: I verified that a boolean column with default=True will store False to the database.

smsearcy avatar May 10 '24 15:05 smsearcy