protected function WebformSubmissionConditionsValidator::submitFormRecursive in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::submitFormRecursive()
Recursively unset submission data for form elements that are hidden.
Parameters
array $elements: An array of form elements.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $data: A webform submission's data.
bool $check_access: Flag that determine if the currrent form element's access should be checked.
bool $visible: Flag that determine if the currrent form elements are visible.
1 call to WebformSubmissionConditionsValidator::submitFormRecursive()
- WebformSubmissionConditionsValidator::submitForm in src/
WebformSubmissionConditionsValidator.php - Submit form #states for visible elements.
File
- src/
WebformSubmissionConditionsValidator.php, line 427
Class
- WebformSubmissionConditionsValidator
- Webform submission conditions (#states) validator.
Namespace
Drupal\webformCode
protected function submitFormRecursive(array $elements, WebformSubmissionInterface $webform_submission, array &$data, $check_access, $visible = TRUE) {
foreach ($elements as $key => &$element) {
if (!WebformElementHelper::isElement($element, $key)) {
continue;
}
// Skip if element's #states_clear is FALSE.
if (isset($element['#states_clear']) && $element['#states_clear'] === FALSE) {
continue;
}
// Skip if element #_webform_access should be checked to
// preserve default values.
if ($check_access && isset($element['#_webform_access']) && $element['#_webform_access'] === FALSE) {
continue;
}
// Determine if the element is visible.
$element_visible = $visible && $this
->isElementVisible($element, $webform_submission) ? TRUE : FALSE;
// Set data to empty array or string for any webform element that is hidden.
if (!$element_visible && !empty($element['#webform_key']) && isset($data[$key])) {
$data[$key] = is_array($data[$key]) ? [] : '';
}
$this
->submitFormRecursive($element, $webform_submission, $data, $check_access, $element_visible);
}
}