Skip to content

Boolean fields with default="false" are saved as null #7581

@lexiclevenger

Description

@lexiclevenger

Describe the bug
When a boolean field has the attribute default="false" in the view definition, the value is saved as null instead of false.

When left blank, boolean fields are always saved as null. If the value was originally saved as true but the box gets unchecked, it is saved as false. Now, some values in the database are false and some are null despite appearing exactly the same on the form and possibly having the same meaning to the user. After this happens, users cannot change the value back to null using data entry forms. Having the ability to set the default as false would give users more control over the consistency of their data.

To Reproduce
Steps to reproduce the behavior:

  1. Go to App Resources and choose a form definition
  2. Click on Collection Object, add this to the view definition, and save
		<row>
<cell type="field" id="yn1" name="yesNo1" uitype="checkbox" colspan="3" default="False"/>
		</row>
  1. Create a new Collection Object record
  2. Fill out required fields and save, leaving the yesNo1 field blank
  3. Create a Collection Object query
  4. Add the catalogNumber field and make it equal to the record you created
  5. Add the yesNo1 field
  6. Run the query and see the value is null instead of False

Expected behavior
The value should be False by default, as defined in the view definition.

Screenshots

Image

https://ojsmnh20250910-main.test.specifysystems.org/specify/view/collectionobject/65678/

Specify 7 System Information - 2025-12-08T20_26_20.257Z.txt

Please fill out the following information manually:

Metadata

Metadata

Assignees

No one assigned

    Labels

    2 - FormsIssues that are related to the form system

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions