Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

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 database field/_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 only:
$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 CreditCardExpirationMonth/CreditCardExpirationYear virtual fields.
$object->SetDBField('CreditCardExpirationMonth', '05');
$object->SetDBField('CreditCardExpirationYear', '24');
$object->Update(); // The 'CreditCardExpiration' field now has combined value of the above set fields.

// ❌ Sets the credit card expiration using the database field only.
$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 solutions marked with the ❌ sign don’t allow for clearing the field's existing value.

Solution

Update the “\kDateFormatter::UpdateSubFields” and “\kCCDateFormatter::UpdateSubFields” methods to support empty values.

Related Tasks

INP-1886 - Getting issue details... STATUS

  • No labels