本文整理汇总了PHP中CRM_Utils_Rule::moneySigned方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Rule::moneySigned方法的具体用法?PHP CRM_Utils_Rule::moneySigned怎么用?PHP CRM_Utils_Rule::moneySigned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Rule
的用法示例。
在下文中一共展示了CRM_Utils_Rule::moneySigned方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formRule
//.........这里部分代码省略.........
}
// allow for 0 value.
if (!empty($fields['option_name'][$index]) || strlen($fields['option_name'][$index]) > 0) {
$noAmount = 0;
}
if (!empty($fields['option_weight'][$index])) {
$noWeight = 0;
$duplicateIndex = CRM_Utils_Array::key($fields['option_weight'][$index], $fields['option_weight']);
if (!($duplicateIndex === false) && !($duplicateIndex == $index)) {
$errors["option_weight[{$index}]"] = ts('Duplicate weight value');
}
}
if ($noLabel && !$noAmount) {
$errors["option_label[{$index}]"] = ts('Label cannot be empty.');
}
if (!$noLabel && $noAmount) {
$errors["option_name[{$index}]"] = ts('Amount cannot be empty.');
}
if ($noLabel && $noAmount) {
$countemptyrows++;
}
}
if ($countemptyrows == 11) {
$errors["option_label[1]"] = $errors["option_name[1]"] = ts('Label and value cannot be empty.');
}
}
$_showHide =& new CRM_Core_ShowHideBlocks('', '');
// do not process if no option rows were submitted
if (empty($fields['option_name']) && empty($fields['option_label'])) {
return true;
}
if (empty($fields['option_name'])) {
$fields['option_name'] = array();
}
if (empty($fields['option_label'])) {
$fields['option_label'] = array();
}
$dupeLabels = array();
$count = 0;
for ($idx = 1; $idx <= self::NUM_OPTION; $idx++) {
$_flagOption = 0;
$_rowError = 0;
$showBlocks = 'optionField_' . $idx;
// both value and label are empty
if ($fields['option_name'][$idx] == '' && $fields['option_label'][$idx] == '') {
$_showHide->addHide($showBlocks);
$count++;
if ($count == 11) {
$showBlocks = 'optionField_' . '1';
$_showHide->addShow($showBlocks);
}
continue;
}
$_showHide->addShow($showBlocks);
if ($fields['option_name'][$idx] != '') {
// check for empty label
if ($fields['option_label'][$idx] == '') {
$errors['option_label][' . $idx . ']'] = ts('Option label cannot be empty');
}
// all fields are money fields
if (!CRM_Utils_Rule::moneySigned($fields['option_name'][$idx])) {
$_flagOption = 1;
$errors['option_name[' . $idx . ']'] = ts('Please enter a valid money value.');
}
}
if ($fields['option_label'][$idx] != '') {
// check for empty value
if ($fields['option_name'][$idx] == '') {
$errors['option_name][' . $idx . ']'] = ts('Option value cannot be empty');
}
// check for duplicate labels, if not already done
if (isset($dupeLabels[$idx])) {
continue;
}
$also_in = array_keys($fields['option_label'], $fields['option_label'][$idx]);
// first match is always the current key
unset($also_in[0]);
if (!empty($also_in)) {
$_flagOption = 1;
$errors['option_label][' . $idx . ']'] = ts('Duplicate Option label');
foreach ($also_in as $also_in_key) {
$errors['option_name][' . $also_in_key . ']'] = ts('Duplicate Option label');
$dupeValues[$also_in_key] = true;
}
}
}
if ($_flagOption) {
$_showHide->addShow($showBlocks);
$_rowError = 1;
}
// last row - hide "Additional Option" option
if ($idx == self::NUM_OPTION) {
$hideBlock = 'additionalOption';
$_showHide->addHide($hideBlock);
}
}
$_showHide->addToTemplate();
}
return empty($errors) ? true : $errors;
}