This looks like a solid plugin, but it would be nice to be able to select which phone fields are given as options. For instance, I will never use a fax number or extension anywhere on my site, ever, so I'd like to disable those fields.

Looking into the code, it seems to me like the way to do this would be to split the formatter into separate functions for Phone, Extension, Mobile, and Fax and then separate the formatter function similarly. This would create separate handlers for each field. Optimally it seems like the UI should be as in the following image, but a way to do that isn't readily apparent.

If anyone has feedback on this I'd appreciate it, otherwise I might start mucking around myself.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donapis’s picture

I'm looking forward for this feature

anni’s picture

I´m hoping for a solution too.

scotthooker’s picture

Seeing as that comment was made back in December. I'm going to try and patch this now. Bear with me.

scotthooker’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
8.3 KB

Patch attached to give config options of what phone fields you want displayed.

Comments appreciated and I'll make the required amends.

AaronBauman’s picture

patch in #4 works great, thanks Scott.

Since there are only 4 options, I like the proposal in the OP better, however, to use checkboxes instead of a multi-select list.
Also, patch in #4 contains leftover help text from Countries field, and some whitespace changes that are unrelated.

Here's an updated patch with those changes.

MoRphlnE’s picture

Thank you, I'll give it a try.

froboy’s picture

Thanks for the work scott and aaron. I had to apply the patch in #5 manually (it doesn't look like a git-generated patch), but once I did it changed the selectors but didn't seem to have an effect on the field display. That is, I was able to check some fields but all of the phone fields still remained. aaronbauman, could you check your patch out and resubmit?

Zito’s picture

Same issue

jcisio’s picture

Status: Needs review » Needs work

Because of #7 and #8.

basvredeling’s picture

Status: Needs work » Needs review
FileSize
5.21 KB

Try this patch

scotthooker’s picture

Sorry only just seen these comments progressing on from my patch in 4.

It was a quick job. Happy to review any patches / make any amends.

nbchip’s picture

For already instantiated fields u need one more "if" in phone.inc line 31

if (isset($context['instance']['widget']['settings']['phone_number_fields'])){
    $settings = $context['instance']['widget']['settings']['phone_number_fields'];
}
ShaneOnABike’s picture

Status: Needs review » Reviewed & tested by the community

I tested this and it works great thanks very much!

jcisio’s picture

Status: Reviewed & tested by the community » Needs work

Per #12. For fields instantiated before this patch, all numbers should be displayed.

scotthooker’s picture

#12 & #14 yep correct fields before this patch, all numbers are displayed.

basvredeling’s picture

Status: Needs work » Needs review
FileSize
5.36 KB

I've created a new patch. Needs to be tested. I've added the remark of #14 jcisio. All numbers also need to be visible for uninstantiated fields. So I put an extra check in each if().

tyler.frankenstein’s picture

For those interested in a hook_form_alter() approach, this example code can be used to hide the mobile and fax number fields:

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout') {
    $form['customer_profile_billing']['commerce_customer_address']['und'][0]['phone_block']['mobile_number']['#access'] = false;
    $form['customer_profile_billing']['commerce_customer_address']['und'][0]['phone_block']['fax_number']['#access'] = false;
  }
}

The place to put the #access value is buried pretty deep in the form, be sure to use a call to dpm($form) to find the correct location to set #access on the form.

kvoltz’s picture

Any chance on this getting rolled into a new commit?

Thanks for the awesome module!

2ndmile’s picture

#16 Tested and Working

drclaw’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Also Tested and can confirm it works. Marking as RTBC

jcisio’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks all for patch and reviews.

  • Commit 945b358 on 7.x-1.x by jcisio:
    Issue #1874490 by basvredeling, aaronbauman, scotthooker | froboy:...
drclaw’s picture

Nice!

andriyun’s picture

FileSize
6.16 KB

Hello guys!
I'm don't see this changes and not undrestend why :(

I'm install dev branch addressfield_phone and dependesies stable branch addressfield.

In field setting form show old checkbox list
Foem settings

Please help! :)

Status: Fixed » Closed (fixed)

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

annya’s picture

Status: Closed (fixed) » Active

I reopen this issue, cause this feature doesn't implement now, because this commit was reverted here.

@jcisio could you tell what's wrong with this patch? I can remake it if it's necessary.

  • Commit 9f57caa on 7.x-1.x by jcisio:
    Issue #1874490 by basvredeling, aaronbauman, scotthooker | froboy:...
jcisio’s picture

Status: Active » Fixed

I wanted to revert 4ce1f3d and commit again with proper attribution (75c6690 right after that) but it reverted both this commit and 945b358 which came after.

Now I recommitted 945b358 and pushed as 9f57caa. Sorry for the confusion.

Status: Fixed » Closed (fixed)

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

kopeboy’s picture

Status: Closed (fixed) » Fixed

What about a stable release?

Status: Fixed » Closed (fixed)

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