You are here

function CC_formatter_default in Phone Number 7

Same name and namespace in other branches
  1. 6 includes/API.php \CC_formatter_default()

Default formatter for international phone number.

Parameters

$element: $element['#item']['country_codes']: alpha-2 country code $element['#item']['number']: phone number

$error: The error message to shown to user. Available parameters to use in the error message are

  • "%countrycode": the alpha-2 CC (check_plain'ed)
  • "%phone_input": the original number input by user (check_plain'ed)
  • "%min_length": allowed minimum length of the phone number
  • "%max_length": allowed maximum length of the phone number
  • "%ext_input": the original extension input by user (check_plain'ed)
  • "%ext_max_length": allowed maximum length of the phone extension

Return value

boolean TRUE if it is a valid phone number for that country, FALSE otherwise.

File

includes/API.php, line 131
Phone Number custom country API

Code

function CC_formatter_default($element) {
  $item = $element['#item'];

  // Display a global phone number with country code.
  $cc = cck_phone_countrycodes($item['country_codes']);

  // Format the phone number however you like, this is the default
  $phone = $cc['code'] . '-' . $item['number'];
  return $phone;
}