case 'Float':
if ($field->is_search_range && $search) {
- $qf->addRule($elementName . '_from', ts('%1 From must be a number (with or without decimal point).', [1 => $label]), 'numeric');
- $qf->addRule($elementName . '_to', ts('%1 To must be a number (with or without decimal point).', [1 => $label]), 'numeric');
+ $qf->addRule($elementName . '_from', ts('%1 From must be a number (with or without decimals).', [1 => $label]), 'numeric');
+ $qf->addRule($elementName . '_to', ts('%1 To must be a number (with or without decimals).', [1 => $label]), 'numeric');
}
elseif ($widget == 'Text') {
- $qf->addRule($elementName, ts('%1 must be a number (with or without decimal point).', [1 => $label]), 'numeric');
+ $qf->addRule($elementName, ts('%1 must be a number (with or without decimals).', [1 => $label]), 'numeric');
}
break;
case 'Money':
if ($field->is_search_range && $search) {
- $qf->addRule($elementName . '_from', ts('%1 From must in proper money format. (decimal point/comma/space is allowed).', [1 => $label]), 'money');
- $qf->addRule($elementName . '_to', ts('%1 To must in proper money format. (decimal point/comma/space is allowed).', [1 => $label]), 'money');
+ $qf->addRule($elementName . '_from', ts('%1 From must in money format (a number with or without decimals, ex: %2).', [1 => $label, 2 => Civi::format()->number(123.98)]), 'money');
+ $qf->addRule($elementName . '_to', ts('%1 To must in money format (a number with or without decimals, ex: %2).', [1 => $label, 2 => Civi::format()->number(123.98)]), 'money');
}
elseif ($widget == 'Text') {
- $qf->addRule($elementName, ts('%1 must be in proper money format. (decimal point/comma/space is allowed).', [1 => $label]), 'money');
+ $qf->addRule($elementName, ts('%1 must be in money format (a number with or without decimals, ex: %2).', [1 => $label, 2 => Civi::format()->number(123.98)]), 'money');
}
break;
switch ($dataType) {
case 'Int':
$ruleName = 'integer';
- $errorMsg = ts('%1 must be an integer (whole number).',
- [1 => $fieldTitle]
- );
+ $errorMsg = ts('%1 must be an integer (whole number).', [1 => $fieldTitle]);
break;
case 'Money':
$ruleName = 'money';
- $errorMsg = ts('%1 must in proper money format. (decimal point/comma/space is allowed).',
- [1 => $fieldTitle]
- );
+ $errorMsg = ts('%1 must be in money format (a number with or without decimals, ex: %2).', [1 => $fieldTitle, 2 => Civi::format()->number(123.98)]);
break;
case 'Float':
$ruleName = 'numeric';
- $errorMsg = ts('%1 must be a number (with or without decimal point).',
- [1 => $fieldTitle]
- );
+ $errorMsg = ts('%1 must be a number (with or without decimals).', [1 => $fieldTitle]);
break;
case 'Link':
$ruleName = 'wikiURL';
- $errorMsg = ts('%1 must be valid Website.',
- [1 => $fieldTitle]
- );
+ $errorMsg = ts('%1 must be valid Website.', [1 => $fieldTitle]);
break;
}
public function setUp(): void {
parent::setUp();
+ CRM_Core_I18n::singleton()->setLocale('en_US');
+ CRM_Core_Config::singleton()->defaultCurrency = 'USD';
+ CRM_Core_Config::singleton()->monetaryThousandSeparator = ',';
+ CRM_Core_Config::singleton()->monetaryDecimalPoint = '.';
$this->custom_group = $this->customGroupCreate(['extends' => 'Case']);
$this->custom_group = $this->custom_group['values'][$this->custom_group['id']];
}
+ public function tearDown(): void {
+ parent::tearDown();
+ CRM_Core_Config::singleton()->defaultCurrency = 'USD';
+ CRM_Core_Config::singleton()->monetaryThousandSeparator = ',';
+ CRM_Core_Config::singleton()->monetaryDecimalPoint = '.';
+ CRM_Core_I18n::singleton()->setLocale('en_US');
+ }
+
/**
* Test that changes to custom fields on cases generate the correct details
* body for ChangeCustomData.
CRM_Core_Config::singleton()->monetaryDecimalPoint = ',';
$this->testChangeCustomDataFormattedDetails($input, $expected);
-
- CRM_Core_Config::singleton()->defaultCurrency = 'USD';
- CRM_Core_Config::singleton()->monetaryThousandSeparator = ',';
- CRM_Core_Config::singleton()->monetaryDecimalPoint = '.';
- CRM_Core_I18n::singleton()->setLocale('en_US');
}
/**