public function InternationalPhoneDefaultWidget::formElement in International Phone Field 8
Define the form for the field type.
Inside this method we can define the form used to edit the field type.
Here there is a list of allowed element types: https://goo.gl/XVd4tA
Overrides WidgetInterface::formElement
File
- src/
Plugin/ Field/ FieldWidget/ InternationalPhoneDefaultWidget.php, line 30
Class
- InternationalPhoneDefaultWidget
- Plugin implementation of the 'InternationalPhoneDefaultWidget' widget.
Namespace
Drupal\international_phone\Plugin\Field\FieldWidgetCode
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $formState) {
$element['value'] = $element + [
'#type' => 'textfield',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : '',
'#attributes' => [
'class' => [
'international_phone-number',
],
],
'#attached' => [
'library' => [
'international_phone/international_phone',
],
],
];
return $element;
}