A phone number field for the SilverStripe CMS with validation using libphonenumber.
- SilverStripe ^4 | ^5
- libphonenumber-for-php
- SilverStripe Userforms (optional)
composer require "6fdigital/silverstripe-phone-field"
The PhoneField
can be used in your custom forms and with the
SilverStripe Userforms module. For usage in your custom Forms
simply add the form to your field list:
use SixF\PhoneField\PhoneField;
public function MyForm(): Form {
return Form::create(
$this,
"MyForm",
FieldList::create(
...
PhoneField::create('PhoneNumber', 'Your Phone Number')
...
),
FieldList::create(
FormAction::create('doSubmit', 'Submit')
),
RequiredFields::create('Phone')
);
}
}