Phone

This field type renders a phone field.

Parameters

Parameters are inherited from the Text field type, with these extra ones:

  • countries - an array of country codes to restrict the available prefixes;

  • country - a country code for the default prefix selected.

Example

The code below renders a required phone field with the custom_field name, "Custom field" label and "Custom text" placeholder. It allows the USA and Great Britain phone numbers only, with the USA code selected by default.

echo ( new HivePress\Fields\Phone(
	[
		'name'        => 'custom_field',
		'label'       => 'Custom field',
		'placeholder' => 'Custom text',
		'countries'   => [ 'USA', 'GB' ],
		'country'     => 'USA',
		'required'    => true,
	]
) )->render();

Last updated