public function perform(HTML_QuickForm2_Controller_Page $page, $name) { $validate = false; $datasources = $page->getForm()->getDataSources(); $container = $page->getController()->getSessionContainer(); list(, $oldName) = $page->getController()->getActionName(); // Check the original action name, we need to do additional processing // if it was 'display' if ('display' == $oldName) { // In case of wizard-type controller we should not allow access to // a page unless all previous pages are valid (see also bug #2323) if ($page->getController()->isWizard() && !$page->getController()->isValid($page)) { return $page->getController()->getFirstInvalidPage()->handle('jump'); } // If we have values in container then we should inject the Session // DataSource, if page was invalid previously we should later call // validate() to get the errors if (count($container->getValues($page->getForm()->getId()))) { array_unshift($datasources, new HTML_QuickForm2_DataSource_Session($container->getValues($page->getForm()->getId()))); $validate = false === $container->getValidationStatus($page->getForm()->getId()); } } // Add "defaults" datasources stored in session $page->getForm()->setDataSources(array_merge($datasources, $container->getDatasources())); $page->populateFormOnce(); if ($validate) { $page->getForm()->validate(); } return $this->renderForm($page->getForm()); }
/** * Adds a new page to the form * * @param HTML_QuickForm2_Controller_Page $page */ public function addPage(HTML_QuickForm2_Controller_Page $page) { $pageId = $page->getForm()->getId(); if (!empty($this->pages[$pageId])) { throw new HTML_QuickForm2_InvalidArgumentException("Duplicate page ID '{$pageId}'"); } $page->setController($this); $this->pages[$pageId] = $page; }