protected function YamlFormSubmissionForm::displayCurrentPage in YAML Form 8
Set form wizard current page.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to YamlFormSubmissionForm::displayCurrentPage()
- YamlFormSubmissionForm::form in src/
YamlFormSubmissionForm.php - Gets the actual form array to be built.
File
- src/
YamlFormSubmissionForm.php, line 1014
Class
- YamlFormSubmissionForm
- Provides a form to collect and edit submissions.
Namespace
Drupal\yamlformCode
protected function displayCurrentPage(array &$form, FormStateInterface $form_state) {
$current_page = $this
->getCurrentPage($form, $form_state);
if ($current_page == 'preview') {
// Hide elements.
$form['elements']['#access'] = FALSE;
// Display preview message.
$this->messageManager
->display(YamlFormMessageManagerInterface::FORM_PREVIEW_MESSAGE, 'warning');
// Build preview.
$form['preview'] = [
'#theme' => 'yamlform_submission_html',
'#yamlform_submission' => $this->entity,
];
}
else {
// Get all pages so that we can also hide skipped pages.
$pages = $this
->getYamlForm()
->getPages();
foreach ($pages as $page_key => $page) {
if (isset($form['elements'][$page_key])) {
if ($page_key != $current_page) {
$form['elements'][$page_key]['#access'] = FALSE;
$this
->hideElements($form['elements'][$page_key]);
}
else {
$form['elements'][$page_key]['#type'] = 'container';
}
}
}
}
}