Documentation

CheckFields

boolean
CCurrency::CheckFields(
 $ACTION,
 &$arFields
 $strCurrencyID = false
);

Verifies currency fields when adding or updating. Non-static method.

Method parameters

Parameter Description
ACTION It equals ADD or UPDATE, case sensitive. If the value is in another case, or has another value - false is returned without an error text (exception). If the value equals to UPDATE, then CurrencyID is verified additionally. If the values is empty - an error is returned, if its not empty, then it will be reduced to 3 symbols.
arFields Keys:
  • CURRENCY - (required), it is reduced to 3 symbols. It is subject to mandatory verification, if available in the array (even if via an update). Additionally, when added, it will be checked for format - 3 Latin symbols. (however, during an update, such check is not performed to preserve compatibility.) If the format is correct, search is executed - to check if such currency already exists (NON-case-sensitive). If it doesn't exist - currency code will be converted to upper case. During updates, the check for availability in the CheckFields method is not performed.
  • AMOUNT_CNT - nominal parameter value (required). Can be an integer > 0.
  • AMOUNT - basic course (required). It is presented, if there are no rates by dates available. Can be only a real number > 0.
  • SORT - sorting. Integer value. Converted to the integer type.
  • NUMCODE - 3-digits currency code.
  • BASE - (Y/N) flag, specifies is this is the base currency.
  • CREATED_BY - ID of the user, who added the currency.
  • MODIFIED_BY - ID of the last user, who modified the currency.
  • DATE_UPDATE - time of update - defined by the system. If the array has such key - it is deleted.
CurrencyID ID of the updated currency. Optional parameter.

Returned value

If sucessful, returns true. If an error - returns false. Error text can be received via $APPLICATION->GetException().

Examples of use

$arFields = array(
		'CURRENCY' => 'руб',
		'AMOUNT_CNT' => 1,
		'AMOUNT' => 0
	);
	
	$boolRes = CCurrency::CheckFields('ADD', $arFields);
	if (!$boolRes)
	{
		if ($ex = $APPLICATION->GetException())
		{
			$strError = $ex->GetString();
			ShowError($strError);
		}
	}
	
	/*
	Returns errors for CURRENCY and AMOUNT fields
	*/


© «Bitrix24», 2001-2024
Up