You are here

function commerce_userpoints_currencies_form_validate in Commerce userpoints 7

Form validate callback for adding a new currency.

File

./commerce_userpoints.admin.inc, line 144
Administration page callbacks for the commerce_userpoints module.

Code

function commerce_userpoints_currencies_form_validate($form, &$form_state) {

  // Only validate the code for new currencies as changing is not allowed for
  // existing ones.
  if (empty($form_state['commerce_userpoints_currency'])) {
    if (!_commerce_userpoints_validate_uniqueness($form_state['values']['code'], 'code')) {
      form_set_error('code', t('The code is already in use for another currency.'));
    }
  }
  if (!_commerce_userpoints_validate_uniqueness($form_state['values']['symbol'], 'symbol', $form_state['values']['code'])) {
    form_set_error('symbol', t('The symbol is already in use for another currency.'));
  }
}