public function WebformSubmissionConditionsValidator::buildPages in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::buildPages()
Apply states (aka conditional logic) to wizard pages.
Parameters
array $pages: An associative array of webform wizard pages.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Return value
array An associative array of webform wizard pages with hidden pages removed.
Overrides WebformSubmissionConditionsValidatorInterface::buildPages
File
- src/
WebformSubmissionConditionsValidator.php, line 70
Class
- WebformSubmissionConditionsValidator
- Webform submission conditions (#states) validator.
Namespace
Drupal\webformCode
public function buildPages(array $pages, WebformSubmissionInterface $webform_submission) {
foreach ($pages as $page_key => $page) {
// Check #access which can be set via form alter.
if ($page['#access'] === FALSE) {
unset($pages[$page_key]);
}
// Check #states (visible/hidden).
if (!empty($page['#states'])) {
$state = key($page['#states']);
$conditions = $page['#states'][$state];
$result = $this
->validateState($state, $conditions, $webform_submission);
if ($result !== NULL && !$result) {
unset($pages[$page_key]);
}
}
}
return $pages;
}