public static function YamlFormCompositeBase::validateYamlFormComposite in YAML Form 8
Validates a composite element.
File
- src/
Element/ YamlFormCompositeBase.php, line 160
Class
- YamlFormCompositeBase
- Provides an base composite form element.
Namespace
Drupal\yamlform\ElementCode
public static function validateYamlFormComposite(&$element, FormStateInterface $form_state, &$complete_form) {
$value = $element['#value'];
// Validate required composite elements.
$composite_elements = static::getCompositeElements();
foreach ($composite_elements as $composite_key => $composite_element) {
if (!empty($element[$composite_key]['#required']) && $value[$composite_key] == '') {
if (isset($element[$composite_key]['#title'])) {
$form_state
->setError($element[$composite_key], t('@name field is required.', [
'@name' => $element[$composite_key]['#title'],
]));
}
}
}
}