The module provides one hook and two helper functions described below.

hook_phonefield_supports_tel

hook_phonefield__supports_tel()

Report if browser supports the tel: schema.

Return value:
bool, TRUE if device supports tel: schema, otherwise FALSE.

For code that may be used for this hook, here are some links that may help you get started:

phonefield_normalize

There are too many number plans and phone number formatting conventions to enforce a “standard” format for phone numbers. All the following example phone numbers are resonable and may be entered as valid phone number in the Phone number field:

In fact, there are no checking of the format, so users can enter anything they like. This has the advantage of supporting any formatting convention.

However, this free format may break the tel: schema if we try to use these human friendly phone numbers in a phone link. This free format also makes ut hard to do phone number lookups. For instance, when the user searches for a phone number, matching with the human friendly format will be hard unless the user enter the exact same formatting as the phone number is stored on the database.

This helper function can be used to normalize the phone number, so that it is suitable for use with the tel: schema and that it can be used for lookup, while keeping the display phone number shown to humans exactly as entered.

phonefield_normalize($phoneno, $link = TRUE)

Normalizes a formatted phone number.

Parameters:
$phoneno: string, a phone number.
$link: bool, if TRUE, format it suitable suitable for a tel:-link by keeping digits and the characters “+” and “-” (and stripping all others);
if FALSE, all non-digits are stripped. This format is stored in a separate field in the database and used for for lookup and matching.
Return value:
string, a normalized version of the phone number.

phonefield_get_entity_id

phonefield_get_entity_id($field, $value)

Look up the entity_id associated with $value in field $field.

Parameters:
$field: string, the field to look up.
$value: string, the value to look up.
Return value:
if lookup successful, an array with the entity_id, bundle and …_linklabel (or FALSE if no result).

For instance, if there is a Phone field named field_phone in the User entity, to look up the username associated with a specific phonenumber, you can do the following:

$eid = phonefield_get_entity_id('field_phone', $phonenumber);
if (isset($eid['entity_id'])) {
  $uid = $eid['entity_id'];
  $username = db_query('SELECT name FROM {users} WHERE uid = :uid',
    array(':uid' => $uid))->fetchfield();
}
else {
  // Username not found.
}