Details
-
Type: Bug
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: 4.7.26
-
Fix Version/s: None
-
Component/s: Core CiviCRM
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
-
Verified?:No
-
How it works currently:A Number field cannot be set to empty, empty values are saved as zero.
-
How it should work:Saving an empty Number Text field should make it NULL.
Description
When using the Number or Money data type, fields are never set to NULL.
Select and radio Number fields will appear empty but still have "0" in the database. Text fields will display the "0" (as per the database).
Reproduced on latest CiviCRM using civicrm-buildkit-vagrant:
- Create a custom field for contacts using the Number data type and the Text field type.
- Create a new contact and leave the field empty.
- See that the field was set to "0" instead of NULL.
Lack of data and "actually zero" can have different meanings.
Compare with Integer fields, which do get correctly set to NULL in the database:
mysql> SELECT * FROM civicrm_value_fundraising_4; +----+-----------+----------------------------+------------------------------+-------------------------------+-------------------+ | id | entity_id | text_number_7 | select_number_8 | radio_number_9| integer_text_okay_10 | +----+-----------+----------------------------+------------------------------+-------------------------------+-------------------+ | 1 | 204 | 0 | 0 | 0 | NULL | +----+-----------+----------------------------+------------------------------+-------------------------------+-------------------+ 1 row in set (0.00 sec)
Attachments
Issue Links
- is supplemented by
-
CRM-21661 Custom number field defaults to 0 for particpant, when none set
- Done/Fixed
- links to