diff --git a/addressfield_phone.module b/addressfield_phone.module index 56dc1d1..fad8ea7 100644 --- a/addressfield_phone.module +++ b/addressfield_phone.module @@ -97,60 +97,50 @@ function addressfield_phone_addressfield_types() { 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'), + $format['phone_block'] = array( + 'phone_number' => array( + '#theme_wrappers' => array('form_element','addressfield_container'), + '#title' => t('Phone'), '#type' => 'addressfield_container', + '#size' => 15, '#attributes' => array('class' => array('phone-number')), - '#tag' => 'div', + '#tag' => 'span', '#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'), + '#access' => !empty($address['phone_number']), + ), + 'phone_number_extension' => array( + '#theme_wrappers' => array('form_element','addressfield_container'), '#title' => t('Phone Extension'), '#type' => 'addressfield_container', '#size' => 10, '#attributes' => array('class' => array('phone-extension')), - '#tag' => 'div', + '#tag' => 'span', '#children' => check_plain($address['phone_number_extension']), - ); - } - if (!empty($address['mobile_number'])) { - $format['phone_block']['mobile_number'] = array( - '#theme_wrappers' => array('addressfield_phone_container'), + '#access' => !empty($address['phone_number_extension']), + ), + 'mobile_number' => array( + '#theme_wrappers' => array('form_element','addressfield_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'), + '#access' => !empty($address['mobile_number']) + ), + 'fax_number' => array( + '#theme_wrappers' => array('form_element','addressfield_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' => 100, - ); - } + '#access' => !empty($address['fax_number']) + ), + '#weight' => 100, + ); return $format; } @@ -205,31 +195,3 @@ function _addressfield_phone_number_options_list() { ); return $types; } - -/** - * Implementation of hook_theme(). - */ -function addressfield_phone_theme() { - $hooks['addressfield_phone_container'] = array( - 'render element' => 'element', - ); - return $hooks; -} - -/** - * Render a container for a set of address fields. - */ -function theme_addressfield_phone_container($variables) { - $element = $variables['element']; - - $element['#children'] = trim($element['#children']); - if (strlen($element['#children']) > 0) { - $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>'; - $output .= '' . $element['#title'] .': ' . $element['#children'] . ''; - $output .= '"; - return $output; - } - else { - return ''; - } -}