public static function YamlFormOtherBase::setOtherError in YAML Form 8
Set element required error.
Parameters
array $element: The form element.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to YamlFormOtherBase::setOtherError()
- YamlFormOtherBase::validateYamlFormOther in src/
Element/ YamlFormOtherBase.php - Validates an other element.
File
- src/
Element/ YamlFormOtherBase.php, line 244
Class
- YamlFormOtherBase
- Base class for form other element.
Namespace
Drupal\yamlform\ElementCode
public static function setOtherError(&$element, FormStateInterface $form_state) {
if (isset($element['#required_error'])) {
$form_state
->setError($element['other'], $element['#required_error']);
}
elseif (isset($element['#title'])) {
$form_state
->setError($element['other'], t('@name field is required.', [
'@name' => $element['#title'],
]));
}
else {
$form_state
->setError($element['other']);
}
}