Custom Field is_required and is_view set to NULL instead of 0 if checkboxes not checked on edit form
May need two separate issues created for this, depends on if we think these are bugs or new expected behavior.
Noticed doing a 'get' API call, CustomField entity, that the is_required and is_view properties are no longer present in API results if they are not checked via the standard custom field edit form.
replicable on dmaster.demo.civicrm.org Create a custom field, and use the API explorer to look at it's properties
$result = civicrm_api3('CustomField', 'get', [
'sequential' => 1,
'id' => 13,
]);
I made a field on dmaster.demo, with id 13
Immediately after field creation, is_required showed 0
Went back and edited the custom field and saved, is_required is not present in the values at all
In the past is_required and is_view properties were present in the results, but had a value of 0.
2 things about this.
- The value stored in the database is now NULL and not 0, I think this is a bug, but IDK. Especially after the field has been edited, the user made a decision that the field is not required, so the data in the database should represent that decision. NULL to me represents no decision.
- If a value is NULL is the API not including the property in the results? This is inconsistent with the 'getfields' call for an entity...the properties returned for a 'get' api action by the 'getfields' request, should match, that is even if the value is NULL, then the API should return 'is_required' => NULL . Code down the line may depend on this property being set...like CiviCRM Entity or other API consumers...In the case of CiviCRM Entity, we specifically set up Drupal entity type metadata based on the 'getfields' call and it is expecting the properties to be there when a 'get' call is made...
for 1) this must be a problem with form post process, to be saving the value as NULL and not 0. Do people see this as a bug, are we setting the is_required and is_view columns to NULL instead of 0 on purpose?
- Do people agree that the expected behavior should be as I describe for the API?