public static function DropdownWidgetType::validateElement in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.2 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.3 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.4 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.5 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.6 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.7 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 8.8 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 10.3.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 10.0.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 10.1.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
- 10.2.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::validateElement()
Form validation handler for widget elements.
Parameters
array $element: The form element.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
File
- modules/
custom/ dropdown/ src/ Plugin/ Field/ FieldWidget/ DropdownWidgetType.php, line 129
Class
- DropdownWidgetType
- Plugin implementation of the 'dropdown_widget_type' widget.
Namespace
Drupal\dropdown\Plugin\Field\FieldWidgetCode
public static function validateElement(array $element, FormStateInterface $form_state) {
if ($element['#required'] && $element['#value'] == '_none') {
$form_state
->setError($element, t('@name field is required.', [
'@name' => $element['#title'],
]));
}
// Save the value in the element key_column.
// Note: there is only one item because the field is not multiple value.
$items = [
$element['#key_column'] => $element['#value'],
];
$form_state
->setValueForElement($element, $items);
}