Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 960 Bytes

telephone.md

File metadata and controls

46 lines (34 loc) · 960 Bytes

Telephone Field

Represents <input> element of type "tel" that lets the user enter and edit a telephone number. Documentation:

Usage Example

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>

Supported Values

  • string
  • null