Submit.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available at through the world-wide-web at |
  11. // | http://www.php.net/license/2_02.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Alexey Borzov <avb@php.net> |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Submit.php 6184 2005-09-07 10:08:17Z bmol $
  20. require_once 'HTML/QuickForm/Action.php';
  21. /**
  22. * The action for a 'submit' button.
  23. *
  24. * @author Alexey Borzov <avb@php.net>
  25. * @package HTML_QuickForm_Controller
  26. * @version $Revision: 6184 $
  27. */
  28. class HTML_QuickForm_Action_Submit extends HTML_QuickForm_Action
  29. {
  30. function perform(&$page, $actionName)
  31. {
  32. // save the form values and validation status to the session
  33. $page->isFormBuilt() or $page->buildForm();
  34. $pageName = $page->getAttribute('id');
  35. $data =& $page->controller->container();
  36. $data['values'][$pageName] = $page->exportValues();
  37. $data['valid'][$pageName] = $page->validate();
  38. // All pages are valid, process
  39. if ($page->controller->isValid()) {
  40. return $page->handle('process');
  41. // Current page is invalid, display it
  42. } elseif (!$data['valid'][$pageName]) {
  43. return $page->handle('display');
  44. // Some other page is invalid, redirect to it
  45. } else {
  46. $target =& $page->controller->getPage($page->controller->findInvalid());
  47. return $target->handle('jump');
  48. }
  49. }
  50. }
  51. ?>