In-Portal uses the database to store the data and HTML to display it. In some cases (e.g., dates, credit card expiration, weight), the user sees a formatted value (e.g. “07/17/2024 2:20 PM“) instead of a database value (e.g. “1721215210“).
Below is the sample PHP code to demonstrate the formatter-powered value update in the database:
// ✅ Set the date using separate date/time virtural fields: $object->SetDBField('FieldName_date', 1721215210); $object->SetDBField('FieldName_time', 1721215210); $object->Update(); // The 'FieldName' field now has combined value of _date/_time fields. // ✅ Set the date using the combined virtual field: $object->SetDBField('FieldName', 1721215210); $object->SetDBField('FieldName_combined', 1); $object->Update(); // The _date/_time fields aren't used. // ❌ Set the date using the database field: $object->SetDBField('FieldName', 1721215210); $object->UpdateFormattersSubFields(array('FieldName')); $object->Update(); // The _date/_time fields are set from the 'FieldName' field. // ❌ Sets the credit card expiration using the database field. $object->SetDBField('CreditCardExpiration', '05/24'); $object->UpdateFormattersSubFields(array('CreditCardExpiration')); $object->Update(); // The _month/_year fields are set from the 'CreditCardExpiration' field.
All solutions work when setting a non-empty value. However, the later 2 solutions don’t work, when there is a need to clear a field value.
Solution
Update the “\kDateFormatter::UpdateSubFields” and “\kCCDateFormatter::UpdateSubFields” methods to support empty values.