Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·130 lines (117 loc) · 3.56 KB
/
Copy pathindex.php
File metadata and controls
executable file
·130 lines (117 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
require_once 'App.php';
/**
* 確認画面つきフォーム
*
* 初期表示フォーム、確認表示フォーム、修正フォームの3種類のフォームの状態をそれぞれの種類のインジェクターでフォームの状態を変えています。
* 画面は初期(修正)画面、確認画面、送信後画面と3つあります。
*/
class Page_Form_Wizard_Index extends App_Page
{
/**
* @var BEAR_Page_Header
*/
private $_header;
/**
* @var array
*/
private $_defaults;
/**
* 最初のフォーム
*/
public function onClickNone(array $args)
{
/** @var App_Form_Wizard_One $form */
$form = BEAR::dependency('App_Form_Wizard_One');
$form->buildOne()->button();
}
/**
* 2番目のフォーム
*
* @param array $args
*/
public function onClickTwo(array $args)
{
/** @var App_Form_Wizard_Two $form */
$form = BEAR::dependency('App_Form_Wizard_Two');
$form->buildTwo()->button();
}
/**
* 3番目のフォーム
*
* @param array $args
*/
public function onClickThree(array $args)
{
/** @var App_Form_Wizard_Three $form */
$form = BEAR::dependency('App_Form_Wizard_Three');
$form->buildThree()->button();
}
/**
* 確認フォームでは3つのフォームをbuildしfreezeします。
*
* @param array $args
*/
public function onClickPreview(array $args)
{
/** @var App_Form_Wizard_Preview $form */
$form = BEAR::dependency('App_Form_Wizard_Preview');
$form->buildOne()->buildTwo()->buildThree()->button();
}
/**
* 確認フォームからサブミット
*
* 画面出力はありませんが、最終的にもう一度フォームのバリデーションを行うためにbuildします
*
* @param array $args
*/
public function onClickAction(array $args)
{
/** @var App_Form_Wizard_Preview $form */
$form = BEAR::dependency('App_Form_Wizard_Preview');
$form->buildOne()->buildTwo()->buildThree()->button();
}
/**
* Inject
*/
public function onInject()
{
parent::onInject();
$this->_header = BEAR::dependency('BEAR_Page_Header');
$this->_defaults = $this->_session->get('wizard_submit');
}
/**
* Output
*/
public function onOutput()
{
$this->display();
}
/**
* Action
*
* フォームの値を次に引き継ぐためにセッションをつかっています。
* hiddenの'_click'という値を次のどのフォームに行くかに利用しています。
*/
public function onAction(array $submit)
{
$submitValues = BEAR_Form::$submitValue; // for BEAR 0.8.0 -
$click = isset($submitValues['_click']) ? $submitValues['_click'] : '';
if ($click === 'action') {
//確認画面から送信ボタンでアクション実行
$this->set('submit', print_r($submit, true));
$this->display('action.tpl');
return;
}
// 次のフォームへ
$wizardSubmit = $this->_session->get('wizard_submit');
$wizardSubmit = is_array($wizardSubmit) ? $wizardSubmit : [];
$this->_session->set('wizard_submit', array_merge($wizardSubmit, $submit));
$options = [
'click' => $click,
'value' => $submit
];
$this->_header->redirect('.', $options);
}
}
App_Main::run('Page_Form_Wizard_Index');