public static function WebformAdminConfigBaseForm::validateBulkFormActions in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Form/AdminConfig/WebformAdminConfigBaseForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigBaseForm::validateBulkFormActions()
Form API callback. Validate bulk form actions.
File
- src/
Form/ AdminConfig/ WebformAdminConfigBaseForm.php, line 114
Class
- WebformAdminConfigBaseForm
- Base webform admin settings form.
Namespace
Drupal\webform\Form\AdminConfigCode
public static function validateBulkFormActions(array &$element, FormStateInterface $form_state) {
$actions_value = NestedArray::getValue($form_state
->getValues(), $element['#parents']);
$enabled_parents = $element['#parents'];
$enabled_parents[1] = str_replace('_actions', '', $enabled_parents[1]);
$enabled_value = NestedArray::getValue($form_state
->getValues(), $enabled_parents);
if (!empty($enabled_value) && empty($actions_value)) {
$form_state
->setErrorByName(NULL, t('@name field is required.', [
'@name' => $element['#title'],
]));
}
// Convert actions associative array of values to an indexed array.
$actions_value = array_values($actions_value);
$element['#value'] = $actions_value;
$form_state
->setValueForElement($element, $actions_value);
}