1

I have a webform, with a field for phone number.

I would like to have another select dropdown field before phone number, with country name and country phone number prefix.

Eg:
Singapore (65)
United Kingdom (44)
Venezuela (58)

2
  • Have you tried drupal.org/project/webform_phone ?
    – Rupesh
    Jun 16, 2015 at 5:43
  • Yes I had tried this, but it does not provides a drop down in the webform, for user to choose their country with country phone code
    – vences
    Jun 16, 2015 at 5:49

1 Answer 1

1

Webform allows you to load options in bulk. Just google for this list and load it into a spreadsheet. Use a bit of find/replace to get it into the format needed by a webform select element, which is:

65|Singapore (65)
44|United Kingdom (44)
58|Venezuela (58)

Then create a webform select field and paste it in.

To get the fields to line up side-by-side (with country code right before phone number and not on a separate line) use the webform_layout module.

3
  • I forgot about this options in bulk! Thank you so much!
    – vences
    Jun 18, 2015 at 8:10
  • This is not a good solution because some countries have the same prefix, so some keys have the same value and this is not allowed
    – kb8
    May 27, 2022 at 8:57
  • You'd have to consolidate the duplicates onto a single line, e.g. if both Country A and Country B share the code 123, then put them on the same line like this: 123|Country A/CountryB (123)
    – Coleman
    May 27, 2022 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.