| // +----------------------------------------------------------------------+ // // $Id: Next.php,v 1.3 2004/03/02 21:15:45 avb Exp $ require_once 'HTML/QuickForm/Action.php'; /** * The action for a 'next' button of wizard-type multipage form. * * @author Alexey Borzov * @package HTML_QuickForm_Controller * @version $Revision: 1.3 $ */ class ConfirmingNext extends HTML_QuickForm_Action { function perform(&$page, $actionName) { // save the form values and validation status to the session $page->isFormBuilt() or $page->buildForm(); $pageName = $page->getAttribute('id'); $data =& $page->controller->container(); $data['values'][$pageName] = $page->exportValues(); $data['valid'][$pageName] = $page->validate(); // Modal form and page is invalid: don't go further if ($page->controller->isModal() && !$data['valid'][$pageName]) { return $page->handle('display'); } //freeze表示をする確認する判定------------------------------- if(!isset($data['_confirmed'][$pageName]) || !$data['_confirmed'][$pageName]){ $data['_confirmed'][$pageName] = true; $page->freeze(); $page->handle('display'); return false; }else { $data['_confirmed'][$pageName] = false; } //freeze表示をする確認する判定------------------------------- // More pages? if (null !== ($nextName = $page->controller->getNextName($pageName))) { $next =& $page->controller->getPage($nextName); $next->handle('jump'); // Consider this a 'finish' button, if there is no explicit one } elseif($page->controller->isModal()) { if ($page->controller->isValid()) { $page->handle('process'); } else { // this should redirect to the first invalid page $page->handle('jump'); } } else { $page->handle('display'); } } } ?> | // +----------------------------------------------------------------------+ // // $Id: Back.php,v 1.3 2004/03/02 21:15:45 avb Exp $ require_once 'HTML/QuickForm/Action.php'; /** * The action for a 'back' button of wizard-type multipage form. * * @author Alexey Borzov * @package HTML_QuickForm_Controller * @version $Revision: 1.3 $ */ class ConfirmingBack extends HTML_QuickForm_Action { function perform(&$page, $actionName) { // save the form values and validation status to the session $page->isFormBuilt() or $page->buildForm(); $pageName = $page->getAttribute('id'); $data =& $page->controller->container(); $data['values'][$pageName] = $page->exportValues(); if (!$page->controller->isModal()) { $data['valid'][$pageName] = $page->validate(); } //freeze表示をする確認する判定------------------------------- $data =& $page->controller->container(); $data['_confirmed'][$pageName] = false; //freeze表示をする確認する判定------------------------------- // get the previous page and go to it // we don't check validation status here, 'jump' handler should if (null === ($prevName = $page->controller->getPrevName($pageName))) { $page->handle('jump'); } else { $prev =& $page->controller->getPage($prevName); $prev->handle('jump'); } } } ?> _formBuilt = true; $this->addElement('text', 'name'); $this->addRule('name', '名前が入力されていません', 'required'); /* $this->addElement('submit', $this->getButtonName('next'), '入力の確認 >>'); このボタンが押されてきているかの判定 そうであれば、freeze確認表示なので、戻るボタンも表示 */ if( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST[$this->getButtonName('next')]) && $this->validate() ){ $buttons[] =& html_quickform::createElement('submit', $this->getButtonName('back'), '<< 戻る'); $buttons[] =& html_quickform::createElement('submit', $this->getButtonName('next'), '次へ >>'); $this->addGroup($buttons, 'submitButton', null, null, false); }else{ $this->addElement('submit', $this->getButtonName('next'), '入力の確認 >>'); } } } class SecondPage extends HTML_QuickForm_Page { function buildForm(){ $this->_formBuilt = true; $this->addElement('textarea', 'comments'); $this->addRule('comments', 'コメントが入力されていません', 'required'); $this->addElement('submit', $this->getButtonName('next'), '登録'); } } class ViewDump extends HTML_QuickForm_Action { function perform(&$page, $actionName){ echo '
';
			var_dump($page->exportValues());
			echo '
'; } } session_start(); $c = new HTML_QuickForm_Controller('test'); $f = new FirstPage('first'); $f->addAction('back', new ConfirmingBack()); //独自のBack $f->addAction('next', new ConfirmingNext()); //独自のNext $c->addPage($f); $c->addPage(new SecondPage('second')); $c->addAction('process', new ViewDump()); $c->run(); echo '
';
	var_dump($_SESSION);
	echo '
'; ?>