I was originally going to post this ticket to the addressfield issue queue, but having looked at some older posts it looks like there is no desire to allow phone number support in the module (see http://drupal.org/node/1317132) so I am posting here. If it's the wrong thing to do I will open the ticket for addressfield rather than addressfield_phone.

Basically, the addressfield_render_address #pre_render function has an if statement to check the field keys:

...
  if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'))) {
...

This is causing the phone fields to be ignored when rendering the address.

Sorry is this isn't the right place to post.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

I think the "right" place depends on how you fix that bug ;) (the bug in the other issue).

calefilm’s picture

I think I am having this problem. Maybe my issue is unrelated. I cannot display a user's phone number in views. In my view:

select,
formatter: default
format handlers: Phone number and extension

Nothing appears.

gloomcheng’s picture

same situation, not only address field phone but also address field nothing appears when set the formatter to default.

gloomcheng’s picture

Updated: There is one way could show address field if set the formatter to 'one line'.

I found some error code below if I set the formatter to 'default', anyone knows what problems?

element_children(NULL) addressfield.module:194
_addressfield_render_address(NULL, NULL) addressfield.module:189
addressfield_render_address(NULL) common.inc:5821
drupal_render(NULL) common.inc:5941
render(NULL) views_handler_field_field.inc:874
views_handler_field_field->render_item(0, Array) views_handler_field.inc:1054
views_handler_field->advanced_render(Object) theme.inc:354
template_preprocess_views_view_field(Array, 'views_view_field') theme.inc:1106
theme(Array, Array) views_handler_field.inc:1515
views_handler_field->theme(Object) views_plugin_style.inc:525
views_plugin_style->render_fields(Array) views_plugin_style.inc:430
views_plugin_style->render_grouping(Array, Array, 1) views_plugin_style.inc:325
views_plugin_style->render(Array) theme.inc:49
template_preprocess_views_view(Array, 'views_view') theme.inc:1106
theme(Array, Array) views_plugin_display.inc:2601
views_plugin_display->render() view.inc:1256
view->render() views_plugin_display_system.inc:319
views_plugin_display_system->execute() view.inc:1337
view->execute_display('system_1', Array) views.module:526
views_page('admin_views_user', 'system_1') 
call_user_func_array('views_page', Array) menu.inc:517
menu_execute_active_handler() index.php:21
sajosh’s picture

Phone number is not showing up with the rest of the Address Fields.

Any ideas on why it's not showing up?

I have a clean install of D7.21, AFP7.x-1.0, and AF7.x-1.0, among many other modules.

jcisio’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

Have you tried the latest dev?

sajosh’s picture

Just tried to install dev but couldn't. I disabled it, uninstalled it, but the 1.0 version still shows up on the List (disabled). I tried installing dev anyway but erred out stating module exists.

So something is wrong with it's uninstall.

Any suggestions?

jcisio’s picture

Priority: Critical » Normal
Status: Active » Closed (duplicate)

It would be your problem. When you delete the 1.0, replace with 1.x-dev, Drupal won't and can't show up the 1.0 version.

Moreover, I think it is a duplicate of #1883286: #pre_render callback requires a return statement.

Stephen Winters’s picture

@ sajosh
I had the same situation, uninstalled Address Field Phone version 7.1.0, but it still showed in the list of modules. I think what happens when you uninstall a module is that the module is uninstalled from the database, but is still present in the Drupal files. I went into CPanel and deleted it from sites/all/modules and then was able to install the 7.x-1.x-dev version of this module.
Stephen

mazdakaps’s picture

hello using the patch i found from the link above ifixed the phone rendering for the views but the result shows all the results in one line without the title. I did some changes and it shows the titles as it should . I put the code below

function _addressfield_phone_render_address($format) {
   $address = $format['#address'];

  $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' => 'span',
      '#children' => check_plain($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' => 'span',
      '#children' => check_plain($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']),
    ),
    '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']),
    ),
  );
omerida’s picture

Issue summary: View changes
Status: Closed (duplicate) » Needs review
FileSize
2.19 KB

Attached patch will only display a phone field if it has a non-empty value.

johannez’s picture

Hi guys,

I combined #10 and #11, put the proper names and added a weight, so that the phone numbers appear after the country (it's strange that the country block has a weight of 100).

This should work for most people.

masher’s picture

Patch #12 worked great. Thanks

Only I had to set '#weight' => 150, to get the phone info below the county

drclaw’s picture

Patch in #12 works well. Seemed a bit weird to run it through a form element theme wrapper though. I added a new theme wrapper for addressfield_phone that outputs the #title in a span next to the phone number.

RKopacz’s picture

just FYI, I was trying to get the phone numbers to display when added as a field to a profile2 profile, using page manager and panels to display the user profile. the patch in #14 did the trick. Thanks to @johannez and @drclaw for pulling that patch together!

Just in case anyone else has a similar problem when using profile2 and page manager / panels.

pcambra’s picture

Status: Needs review » Reviewed & tested by the community

Patch works fine, thanks!

  • jcisio committed 312979d on 7.x-1.x authored by drclaw
    Issue #1883330 by drclaw, johannez, omerida | ls206: Phone fields not...
jcisio’s picture

Status: Reviewed & tested by the community » Fixed

I don't like to add a theme, but as that's the way it works, so committed and pushed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

hitesh.koli’s picture

I used #10 and put proper weight so that it displays below the address.