From ef7bb0e79485976d3321b0885ab60743c715b4cd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 14 May 2014 12:44:12 +0200 Subject: [PATCH] It is a multistep page's responsibility whether it is shown to the user refs #6136 --- library/Icinga/Web/Wizard/Page.php | 14 +++++++++++++- library/Icinga/Web/Wizard/Wizard.php | 8 +++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Wizard/Page.php b/library/Icinga/Web/Wizard/Page.php index fdc0fd171..82e064745 100644 --- a/library/Icinga/Web/Wizard/Page.php +++ b/library/Icinga/Web/Wizard/Page.php @@ -49,6 +49,18 @@ class Page extends Form } + /** + * Return whether this page needs to be shown to the user + * + * Overwrite this to add page specific handling + * + * @return bool + */ + public function isRequired() + { + return true; + } + /** * Set the title for this wizard page * @@ -70,7 +82,7 @@ class Page extends Form } /** - * Return a config containing all values of this wizard page + * Return a config containing all values provided by the user * * @return Zend_Config */ diff --git a/library/Icinga/Web/Wizard/Wizard.php b/library/Icinga/Web/Wizard/Wizard.php index 64e9e5f24..3fc5fa49d 100644 --- a/library/Icinga/Web/Wizard/Wizard.php +++ b/library/Icinga/Web/Wizard/Wizard.php @@ -8,6 +8,12 @@ use Zend_Config; use Icinga\Web\Form; use Icinga\Exception\ProgrammingError; +/** + * Multistep form with support for nesting and dynamic behaviour + * + * @todo Pages that were displayed initially and filled out by the user remain + * currently in the configuration returned by Wizard::getConfig() + */ class Wizard extends Page { /** @@ -31,7 +37,7 @@ class Wizard extends Page */ public function getPages() { - return $this->pages; + return array_filter($this->pages, function ($page) { return $page->isRequired(); }); } /**