Skip to content
Viames Marino edited this page Jun 13, 2026 · 3 revisions

Pair framework: Tel

Pair\Html\FormControls\Tel renders <input type="tel">. For reusable international phone validation, use Form::e164Phone(...) or call preset(FormValidationPreset::E164_PHONE).

Methods

  • render(): string
  • Inherited methods from FormControl: placeholder(), pattern(), minLength(), maxLength(), inputmode(), value(), validate(), preset().

Examples

$phone = (new \Pair\Html\FormControls\Tel('phone'))
    ->placeholder('+1 555 123 4567')
    ->pattern('^[+0-9()\-\s]{6,20}$')
    ->inputmode('tel')
    ->required();

echo $phone->render();

Office extension field:

$ext = (new \Pair\Html\FormControls\Tel('extension'))
    ->maxLength(6)
    ->pattern('^[0-9]{1,6}$');

E.164 phone field:

$mobile = (new \Pair\Html\FormControls\Tel('mobile'))
    // Normalizes separators away and validates the international form.
    ->preset(\Pair\Html\FormValidationPreset::E164_PHONE)
    ->placeholder('+393331234567');

See also: Text, Search, FormControl, FormValidationPreset, PairValidation.js.

Clone this wiki locally