This repository was archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsForm.php
More file actions
124 lines (114 loc) · 3.55 KB
/
SettingsForm.php
File metadata and controls
124 lines (114 loc) · 3.55 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
<?php
/**
* Settings Config form object
*
* PHP Version 5.3
*
* @category Forms
* @package AW
* @author Alex Wyett <alex@wyett.co.uk>
* @copyright 2013 Alex Wyett
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @link http://www.github.com/alexwyett
*/
/**
* Settings Config form object. Extends the generic form and provides a static helper
* method to build the form object
*
* PHP Version 5.3
*
* @category Forms
* @package AW
* @author Alex Wyett <alex@wyett.co.uk>
* @copyright 2013 Alex Wyett
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @link http://www.github.com/alexwyett
*/
class SettingsForm extends \aw\formfields\forms\StaticForm
{
/**
* Constructor
*
* @param array $attributes Form attributes
* @param array $formValues Form Values
* @param string $brandcode Brandcode
*
* @return void
*/
public static function factory(
$attributes = array(),
$formValues = array(),
$brandcode = 'ZZ'
) {
// New form object
$form = new \aw\formfields\forms\Form($attributes, $formValues);
// Fieldset
$fs = \aw\formfields\fields\Fieldset::factory(
'Add a new Setting',
array(
'class' => 'setting-details'
)
);
// Add key field
$fs->addChild(
self::getNewLabelAndSelect(
'Key',
array(
'Select' => '',
'HMAC Security' => 'hmac',
'liveSite' => 'liveSite',
'useNewImageCaching' => 'useNewImageCaching',
'creditCardPercentage (iframe setting, default is 2%)' => 'creditCardPercentage',
'sdCreditCardPercentage (iframe setting, default is 2%)' => 'sdCreditCardPercentage',
'depositType (default is 1/3)' => 'depositType',
'balanceDueDays (default is 28 days)' => 'balanceDueDays',
'petExtraCode (replaces PET)' => 'petExtraCode',
'newDateRangePrice (includes zero price periods)' => 'newDateRangePrice'
)
)->getElementBy('getType', 'select')
->setName('key')
->setId('key')
->setRule('ValidSlug', true)
->getParent()
->setLabel('Setting Name')
);
// Add value field
$fs->addChild(
self::getNewLabelAndTextField(
'Value'
)->getElementBy('getType', 'text')
->setRule('ValidString', true)
->getParent()
);
// Add brandcode
$fs->addChild(
new aw\formfields\fields\HiddenInput(
'brandcode',
array(
'value' => $brandcode
)
)
);
// Add action
$fs->addChild(
new aw\formfields\fields\HiddenInput(
'action',
array(
'value' => 'add-setting'
)
)
);
// Add fieldset to form
$form->addChild($fs);
// Add submit button
$form->addChild(
new \aw\formfields\fields\SubmitButton(
array(
'value' => 'Add Setting',
'id' => 'formsubmitsetting'
)
)
);
return $form->mapValues();
}
}