public function PhoneInternationalDefaultWidget::settingsForm in International Phone 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/PhoneInternationalDefaultWidget.php \Drupal\phone_international\Plugin\Field\FieldWidget\PhoneInternationalDefaultWidget::settingsForm()
- 3.x 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 85
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.'),
];
return $elements;
}