public function PhoneInternationalDefaultWidget::settingsForm in International Phone 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/PhoneInternationalDefaultWidget.php \Drupal\phone_international\Plugin\Field\FieldWidget\PhoneInternationalDefaultWidget::settingsForm()
- 8 src/Plugin/Field/FieldWidget/PhoneInternationalDefaultWidget.php \Drupal\phone_international\Plugin\Field\FieldWidget\PhoneInternationalDefaultWidget::settingsForm()
Returns a form to configure settings for the widget.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form definition for the widget settings.
Overrides WidgetBase::settingsForm
File
- src/
Plugin/ Field/ FieldWidget/ PhoneInternationalDefaultWidget.php, line 55
Class
- PhoneInternationalDefaultWidget
- Plugin implementation of the 'phone_international_widget' widget.
Namespace
Drupal\phone_international\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = [];
$elements['geolocation'] = [
'#type' => 'checkbox',
'#title' => t('Enable Geolocation'),
'#default_value' => $this
->getSetting('geolocation'),
];
$countries = CountryManager::getStandardList();
$elements['initial_country'] = [
'#type' => 'select',
'#title' => t('Initial Country'),
'#options' => $countries,
'#default_value' => $this
->getSetting('initial_country'),
'#description' => t('Set default selected country to use in phone field.'),
];
$elements['exclude_countries'] = [
'#type' => 'select',
'#title' => t('Exclude Countries'),
'#options' => $countries,
'#multiple' => TRUE,
'#default_value' => $this
->getSetting('exclude_countries'),
'#description' => t('In the dropdown, display all countries except the ones you specify here.'),
];
$elements['preferred_countries'] = [
'#type' => 'select',
'#title' => t('Preferred Countries'),
'#multiple' => TRUE,
'#options' => $countries,
'#default_value' => $this
->getSetting('preferred_countries'),
'#description' => t('Set the initial country selection by specifying its country code. If you leave Preferred Countries blank, it will default to the first country in the list.'),
];
return $elements;
}