caldera_forms_phone_js_options

Caldera Forms Banner

This filter was added in Caldera Forms 1.5.0

You can use this filter to change the default options that the field loads.

This filter exposes 3 parameters:

  • $options – This is an array of the available options for the phone better field.
    • $options[ ‘initialCountry’ ] – Used to set the default country that the phone better field loads. Accepts ISO_3166-1_alpha-2 formatted country codes.
    • $options[ ‘autoHideDialCode’ ] – Used to show or hide the numeric prefix. Accepts boolean.
    • $options[ ‘utilsScript’ ] – Used to load your own utility JavaScript file with a custom filepath.
    • $options[ ‘preferredCountries’ ] – Used to specify the countries to appear at the top of the list. Accepts array of country codes.
  • $field – Field config.
  • $form – Form config.

Country codes must be supplied as ISO_3166-1_alpha-2 country codes.

Change Initial Country For Caldera Forms Phone Fields

 

Set Countries To Appear At The Top Of The Caldera Forms Phone Field List

Only Show Specific Countries In Caldera Forms Phone Field

Where Does This Code Go?

When using WordPress hooks to customize Caldera Forms or other plugins you should not modify the plugin files, or you will lose your changes when you update the plugin. Instead you should create a small plugin to hold the custom code. It's easy, learn how here.

Technically you can add the custom code to your theme's functions.php, but then you will not be able to change your theme and keep these customizations.

Learn More