You are here

function _addressfield_phone_render_address in Address Field Phone 7

1 string reference to '_addressfield_phone_render_address'
addressfield_format_phone_generate in plugins/format/phone.inc
Format callback.

File

./addressfield_phone.module, line 219
Add additional phone fields to addressfield.

Code

function _addressfield_phone_render_address($format) {
  $address = $format['#address'];
  $format['phone_block'] = array();
  if (!empty($address['phone_number'])) {
    $format['phone_block']['phone_number'] = array(
      '#theme_wrappers' => array(
        'addressfield_phone_container',
      ),
      '#title' => t('Phone'),
      '#type' => 'addressfield_container',
      '#attributes' => array(
        'class' => array(
          'phone-number',
        ),
      ),
      '#tag' => 'div',
      '#children' => check_plain($address['phone_number']),
    );
  }
  if (!empty($address['phone_number_extension'])) {
    $format['phone_block']['phone_number_extension'] = array(
      '#theme_wrappers' => array(
        'addressfield_phone_container',
      ),
      '#title' => t('Phone Extension'),
      '#type' => 'addressfield_container',
      '#size' => 10,
      '#attributes' => array(
        'class' => array(
          'phone-extension',
        ),
      ),
      '#tag' => 'div',
      '#children' => check_plain($address['phone_number_extension']),
    );
  }
  if (!empty($address['mobile_number'])) {
    $format['phone_block']['mobile_number'] = array(
      '#theme_wrappers' => array(
        'addressfield_phone_container',
      ),
      '#title' => t('Mobile Number'),
      '#type' => 'addressfield_container',
      '#size' => 15,
      '#attributes' => array(
        'class' => array(
          'phone-number',
        ),
      ),
      '#tag' => 'div',
      '#children' => check_plain($address['mobile_number']),
    );
  }
  if (!empty($address['fax_number'])) {
    $format['phone_block']['fax_number'] = array(
      '#theme_wrappers' => array(
        'addressfield_phone_container',
      ),
      '#title' => t('Fax Number'),
      '#type' => 'addressfield_container',
      '#size' => 15,
      '#attributes' => array(
        'class' => array(
          'phone-number',
        ),
      ),
      '#tag' => 'div',
      '#children' => check_plain($address['fax_number']),
    );
  }
  if (!empty($format['phone_block'])) {
    $format['phone_block'] += array(
      '#type' => 'addressfield_container',
      '#attributes' => array(
        'class' => array(
          'addressfield-phone-block',
        ),
      ),
      '#weight' => 200,
    );
  }
  return $format;
}