-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOne.php
executable file
·85 lines (76 loc) · 2.88 KB
/
One.php
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
<?php
/**
* エントリーフォーム
*
* Wizardフォーム最初のフォームです。
* このフォームは2番目、3番目..フォームでも継承され_attrプロパティとして設定しているフォームのアトリビュートは共通して使われます。
*
* + UA別インジェクタを使用するとこのアトリビュートが変化します。
* + hiddenの"click"で次のフォームが指定しページのonAction()で利用しています。
* + ボタンのレンダリングを変えるため標準の"radio"からBEARオリジナルの"bradio"にしています。
*/
class App_Form_Wizard_One extends BEAR_Base
{
/**
* フォーム設定
*
* @var array
*/
protected $_formConfig = [
'formName' => 'form',
'callback' => ['App_Form_Wizard_One', 'onRenderFreeze']
];
/**
* @var HTML_QuickForm
*/
protected $_form;
/**
* アトリビュート
*
* @var array
*/
protected $_attr = [
'name' => 'size="30" maxlength="30"',
'email' => 'size="30" maxlength="30"',
'comment' => 'rows="20" cols="40"'];
/**
* フォームテンプレート
*
* @var string
*/
private static $_elementTemplate = "\n\t\t<li><label class=\"element\"><!-- BEGIN required --><span class=\"required\">*</span><!-- END required -->{label}</label><div class=\"element<!-- BEGIN error -->_error<!-- END error -->\">{element}<!-- BEGIN error --><span class=\"form-element-error\" alt=\"!\"><img src=\"/image/warning.gif\"><!-- END error --></div></li>";
public function onInject()
{
$this->_form = BEAR::factory('BEAR_Form', $this->_formConfig);
$this->_form->addElement('header', 'main', 'Wizard One');
$this->_form->addElement('hidden', '_click', 'two');
}
/**
* フォーム
*/
public function buildOne()
{
// エレメント
$this->_form->addElement('text', 'name', '名前', $this->_attr['name']);
$radio[] = (new HTML_QuickForm)->createElement('bradio', null, null, '男性', 'M');
$radio[] = (new HTML_QuickForm)->createElement('bradio', null, null, '女性', 'F');
$this->_form->addGroup($radio, 'gender', '性別');
// ルール
$this->_form->addRule('name', '名前を入力してください', 'required');
$this->_form->addRule('gender', '性別を入力してください', 'required');
return $this;
}
public function button()
{
$this->_form->addElement('submit', '_submit', '次へ', '');
}
/**
* カスタムテンプレート
*
* @see http://pear.php.net/manual/ja/package.html.html-quickform-renderer-tableless.php
*/
public static function onRenderFreeze(HTML_QuickForm_Renderer_Tableless $render)
{
$render->setElementTemplate(self::$_elementTemplate);
}
}