public static function IssueWidget::validateElement in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/IssueWidget.php \Drupal\simplenews\Plugin\Field\FieldWidget\IssueWidget::validateElement()
Form validation handler for widget elements.
Parameters
array $element: The form element.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Overrides OptionsWidgetBase::validateElement
File
- src/
Plugin/ Field/ FieldWidget/ IssueWidget.php, line 150
Class
- IssueWidget
- Plugin implementation of the 'simplenews_issue' widget.
Namespace
Drupal\simplenews\Plugin\Field\FieldWidgetCode
public static function validateElement(array $element, FormStateInterface $form_state) {
// OptionsWidgetBase uses '_none' as a special value.
if ($element['#value'] == '_none') {
if ($element['#required']) {
$form_state
->setError($element, t('@name field is required.', [
'@name' => $element['#title'],
]));
}
else {
$form_state
->setValueForElement($element, NULL);
}
}
}