Merge pull request #15821 from seamuslee001/dev_core_183_custom_group
[civicrm-core.git] / CRM / Core / QuickForm / Action / Refresh.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Redefine the refresh action.
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 * $Id$
18 *
19 */
20 class CRM_Core_QuickForm_Action_Refresh extends CRM_Core_QuickForm_Action {
21
22 /**
23 * Class constructor.
24 *
25 * @param object $stateMachine
26 * Reference to state machine object.
27 *
28 * @return \CRM_Core_QuickForm_Action_Refresh
29 */
30 public function __construct(&$stateMachine) {
31 parent::__construct($stateMachine);
32 }
33
34 /**
35 * Processes the request.
36 *
37 * @param CRM_Core_Form $page
38 * The current form-page.
39 * @param string $actionName
40 * Current action name, as one Action object can serve multiple actions.
41 *
42 * @return void
43 */
44 public function perform(&$page, $actionName) {
45 // save the form values and validation status to the session
46 $page->isFormBuilt() or $page->buildForm();
47
48 $pageName = $page->getAttribute('name');
49 $data = &$page->controller->container();
50 $data['values'][$pageName] = $page->exportValues();
51 $data['valid'][$pageName] = $page->validate();
52
53 // Modal form and page is invalid: don't go further
54 if ($page->controller->isModal() && !$data['valid'][$pageName]) {
55 return $page->handle('display');
56 }
57
58 // the page is valid, process it before we jump to the next state
59 $page->mainProcess();
60
61 return $page->handle('jump');
62 }
63
64 }