Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
Could you add the ability to make a phone number a required field? It would be great if the module would allow you to set a checkbox so that either the primary number or any of the three phone fields would be required for entry by the user. Thanks for your consideration.
Cheers,
Comment | File | Size | Author |
---|---|---|---|
#16 | addressfield_phone-1870974-16.patch | 4.36 KB | tucho |
Comments
Comment #1
kvoltz CreditAttribution: kvoltz commentedAny progress with this? This would be a great feature to add.
Comment #2
svouthi CreditAttribution: svouthi commentedI am interested in this basic functionality also.
Comment #3
sketman CreditAttribution: sketman commentedI would welcome this feature too...
Comment #4
svouthi CreditAttribution: svouthi commentedI went ahead and installed Field Group and Commerce Fieldgroup Panes (since my use case is with Commerce), and created fields as mentioned in this comment, making the phone number field required. Granted, this field has no special formatting, but it is adequate for my needs at present.
Comment #5
jcisio CreditAttribution: jcisio commentedFWIW it's quite easy to make phone number required with something like this:
or even better, in some case:
Comment #6
Jawi CreditAttribution: Jawi commentedThanks jcisio for your input. Do you place this adjustment in a custom module or in the Address Field Phone module?
Comment #7
jcisio CreditAttribution: jcisio commentedFinally I think it does not worth adding this feature that will make the UI having too many options.
Comment #8
millionleaves CreditAttribution: millionleaves as a volunteer commentedThanks to jcisio for the code in #5; this gave me what I wanted. A couple of additional observations for someone looking to use it:
It's a shame this functionality won't be added to the Address Field Phone module, but it's clear the UI would get pretty messy once the scenarios outlined in the 3rd and 4th points are taken into account.
Comment #9
tuchoI attached a patch that add this feature to the module.
It replaces each checkbox for the available fields with a select with 3 states:
I keep the default behavior, so if all the fields are hidden, the four fields are shown in the address form.
I have merged the patch from #2481897: Undefined index in addressfield_format_phone_generate() to avoid some warnings when a field is not selected.
Comment #10
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #11
jcisio CreditAttribution: jcisio commentedThe other issue is fixed, patch needs reroll.
Comment #12
DamienMcKennaRerolled.
Comment #13
DamienMcKennaFYI the other issue didn't completely fix the problem with missing variables, so this should cover it.
Comment #14
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedhttps://www.drupal.org/node/2689889
Comment #15
AporieSo,
None of the solutions above work for me :
1) Patch apply to 7.x-1.3 version and not dev version with the following command (I'm saying it because took me a while to figure it out) :
patch -p1 < thepatch.patch
with the patch in the root folder of addressfield_phone.2) Patch even if patching process worked did nothing .... (didn't see any change, none select list for the checkbox as described in #9)
3)#5 also didn't work with the folowing :
4) Probably all of that come from me because I'm not a php dev, but still, here are my feedbacks.
Comment #16
tuchoPatch re rolled for current 7.x-1.x dev version!
Comment #17
AporieIs there something I have to know, like this patch apply to new fields or whatever ?
Because I'm sorry but still no change ... I'm sorry to annoy you with that.
[edit] So it bother me so much that I directly edited the module files :
In phone.inc, just remove conditionnal directives on the field you want to make required :
'#required' => (!empty($settings['extension']) && $settings['extension'] == 'required'),
Into :
Comment #18
mbreden CreditAttribution: mbreden at Acro Commerce commented#5 didn't work for me, however this did.
Comment #19
StijnBousard CreditAttribution: StijnBousard commentedPatch #16 is exactly what I need! Thanks!
Comment #20
philsward CreditAttribution: philsward commented#16 worked beautifully against 1.4. Unless there's a reason to change how the UX works, (I think it's fine for intended purposes) I'd say let's get this committed.
Comment #21
jcisio CreditAttribution: jcisio commentedPatch looks good. The UI is less clumsy than I thought. Thanks all. Committed and pushed.
Comment #24
No Sssweat CreditAttribution: No Sssweat commentedThis still isn't available in the latest stable version.
Time to release a new version? 7.x-1.5 ?