1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Options for the jquery validate renderer |
4
|
|
|
* |
5
|
|
|
* @category StrokerForm |
6
|
|
|
* @package StrokerForm\Renderer |
7
|
|
|
* @subpackage JqueryValidate |
8
|
|
|
* @copyright 2012 Bram Gerritsen |
9
|
|
|
* @version SVN: $Id$ |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace StrokerForm\Renderer\JqueryValidate; |
13
|
|
|
|
14
|
|
|
class Options extends \StrokerForm\Renderer\Options |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
private $validateOptions = array(); |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var bool |
23
|
|
|
*/ |
24
|
|
|
private $useTwitterBootstrap = true; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $initializeTrigger = '$(document).ready(function(){%s});'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
private $customValidationRules = array(); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var boolean |
38
|
|
|
*/ |
39
|
|
|
private $disableAjaxFallback = false; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public function getValidateOptions() |
45
|
|
|
{ |
46
|
|
|
return $this->validateOptions; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Overwrite default options for the jquery.validate plugin |
51
|
|
|
* See: http://docs.jquery.com/Plugins/Validation#Options_for_the_validate.28.29_method |
52
|
|
|
* |
53
|
|
|
* @param array $validateOptions |
54
|
|
|
*/ |
55
|
|
|
public function setValidateOptions($validateOptions) |
56
|
|
|
{ |
57
|
|
|
$this->validateOptions = $validateOptions; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param string $option |
62
|
|
|
*/ |
63
|
|
|
public function addValidateOption($option) |
64
|
|
|
{ |
65
|
|
|
$this->validateOptions[] = $option; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
|
|
public function isUseTwitterBootstrap() |
72
|
|
|
{ |
73
|
|
|
return $this->useTwitterBootstrap; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param bool $useTwitterBootstrap |
78
|
|
|
*/ |
79
|
|
|
public function setUseTwitterBootstrap($useTwitterBootstrap) |
80
|
|
|
{ |
81
|
|
|
$this->useTwitterBootstrap = $useTwitterBootstrap; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getInitializeTrigger() |
88
|
|
|
{ |
89
|
|
|
return $this->initializeTrigger; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $initializeTrigger |
94
|
|
|
* |
95
|
|
|
* @return Options |
96
|
|
|
*/ |
97
|
|
|
public function setInitializeTrigger($initializeTrigger) |
98
|
|
|
{ |
99
|
|
|
$this->initializeTrigger = $initializeTrigger; |
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return array |
105
|
|
|
*/ |
106
|
|
|
public function getCustomValidationRules() |
107
|
|
|
{ |
108
|
|
|
return $this->customValidationRules; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param array $customValidationRules |
113
|
|
|
* |
114
|
|
|
* @return Options $this |
115
|
|
|
*/ |
116
|
|
|
public function setCustomValidationRules(array $customValidationRules) |
117
|
|
|
{ |
118
|
|
|
$this->customValidationRules = $customValidationRules; |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return boolean |
125
|
|
|
*/ |
126
|
|
|
public function isDisableAjaxFallback() |
127
|
|
|
{ |
128
|
|
|
return $this->disableAjaxFallback; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param boolean $disableAjaxFallback |
133
|
|
|
*/ |
134
|
|
|
public function setDisableAjaxFallback($disableAjaxFallback) |
135
|
|
|
{ |
136
|
|
|
$this->disableAjaxFallback = $disableAjaxFallback; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|