You are here

function theme_phone_number in Phone Number 6

FAPI theme for an individual phone number elements.

The phone number is already rendered by the themes and the html output lives in $element['#children']. Override this theme to make custom changes to the output.

$element['#title'] is the field title $element['#field_name'] contains the field name $element['#delta''] is the position of this element in the group $element['number] is the phone number $element['country_codes'] is the country code

File

./cck_phone.module, line 628
Defines phone number fields for CCK. Provide some verifications on the phone numbers

Code

function theme_phone_number($element) {
  drupal_add_css(drupal_get_path('module', 'cck_phone') . '/cck_phone.css');

  // Prefix single value phone number fields with the name of the field.
  //  if (empty($element['#field']['multiple'])) {
  //    if (isset($element['number']) && isset($element['country_codes'])) {
  //      $element['number']['#title'] = $element['#title'] .' '. $element['number']['#title'];
  //      $element['country_codes']['#title'] = $element['#title'] .' '. $element['country_codes']['#title'];
  //    }
  //    elseif ($element['number']) {
  //      $element['number']['#title'] = $element['#title'];
  //    }
  //  }
  $output = '';
  $output = '<div class="form-item"';
  if (!empty($element['#id'])) {
    $output .= ' id="' . $element['#id'] . '-wrapper"';
  }
  $output .= ">\n";
  $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
  if (!empty($element['#title'])) {
    $title = $element['#title'];
    if (!empty($element['number']['#id'])) {
      $output .= ' <label for="' . $element['number']['#id'] . '">' . t('!title: !required', array(
        '!title' => filter_xss_admin($title),
        '!required' => $required,
      )) . "</label>\n";
    }
    else {
      $output .= ' <label>' . t('!title: !required', array(
        '!title' => filter_xss_admin($title),
        '!required' => $required,
      )) . "</label>\n";
    }
  }
  $output .= '<div class="cck-phone-field clear-block">';
  if (isset($element['number'])) {
    $output .= '<div class="cck-phone-field-phone cck-phone-column">' . theme('textfield', $element['number']) . '</div>';
  }
  if (isset($element['extension'])) {
    $prefix = isset($element['extension']['#prefix']) ? $element['extension']['#prefix'] : '';
    $output .= '<div class="cck-phone-field-ext cck-phone-column">' . $prefix . theme('textfield', $element['extension']) . '</div>';
  }
  $output .= '<div class="cck-phone-field-cc cck-phone-column">' . theme('select', $element['country_codes']) . '</div>';
  $output .= '</div></div>';
  return $output;
}