Represents <input>
element of type "tel" that lets the user enter and edit a telephone number. Documentation:
Form model:
final class ProfileForm extends FormModel
{
public ?string $phone = null;
public function getAttributeLabels(): array
{
return [
'phone' => 'Your phone number',
];
}
}
Widget:
echo Telephone::widget()
->formAttribute($profileForm, 'phone')
->pattern('[0-9]{3}-[0-9]{3}-[0-9]{4}');
Result will be:
<div>
<label for="profileform-phone">Your phone number</label>
<input type="tel" id="profileform-phone" name="ProfileForm[phone]" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}">
</div>
string
null