Fields

Phone ​

Phone is the phone number field. It can render as a basic tel input or use the phone-country module for country selection and validation.

Use this page to preserve the input attributes and, when the country setting is enabled, the hidden country input that keeps the submit payload aligned.

Preview ​

Attributes ​

Phone fields can include both a visible tel input and, when country selection is enabled, a hidden country input.

Field ​

AttributePurposeImportance
data-formie-field-handleStable field identity used by validation and error renderingRequired

Field Input ​

AttributePurposeImportance
input[type="tel"][data-formie-phone-input]Visible phone input selectorRequired for phone-country enhancement
data-formie-inputGeneric Formie input marker included in normal outputRecommended
data-formie-input-idStable visible-input identityRecommended

Country Input ​

AttributePurposeImportance
input[data-formie-phone-country-input]Country-code storage input kept in sync by the moduleRequired when country setting is enabled

Styling Classes ​

These classes are for presentation only. They are not behaviour requirements:

Field Input ​

ClassDescription
formie-inputShared tel-input styling and focus treatment
formie-input-errorError-state styling class

Behaviour ​

The phone-country module:

  • mounts intl-tel-input onto the visible tel input
  • keeps the hidden country input synchronized with the selected ISO country code
  • validates international numbers through the form validator layer

Events ​

Phone-country-enhanced fields emit field events in addition to the broader events documented on JavaScript events.

The formie:field:phone-country:before-init Event ​

Triggered before intl-tel-input is mounted. Use this to change the plugin options before initialisation.

js
document.addEventListener('formie:field:phone-country:before-init', (event) => {
  // Limit the picker to the countries supported by this form.
  event.detail.options.onlyCountries = ['us', 'ca', 'gb'];
});

The formie:field:phone-country:init Event ​

Triggered after the phone input, country synchronization, and validator wiring are ready.

js
document.addEventListener('formie:field:phone-country:init', (event) => {
  const { phoneCountry, validator } = event.detail;

  // Only proceed when the phone input has been enhanced successfully.
  if (!(phoneCountry instanceof HTMLInputElement)) {
    return;
  }

  const selectedCountry = validator.getSelectedCountryData()?.iso2;

  if (!selectedCountry) {
    return;
  }

  // Expose the active country code for custom labels or analytics hooks.
  phoneCountry.closest('[data-formie-field]')?.setAttribute('data-phone-country', selectedCountry.toUpperCase());
});
Last updated: Sep 16, 2026, 3:50 PM