1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\FormElements; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Format numbers |
7
|
|
|
* |
8
|
|
|
* Use CurrencyFormatter to get rules for decimals and grouping separators |
9
|
|
|
* |
10
|
|
|
* @link https://robinherbots.github.io/Inputmask/#/documentation/numeric |
11
|
|
|
*/ |
12
|
|
|
class InputMaskNumericField extends InputMaskField |
13
|
|
|
{ |
14
|
|
|
use CurrencyFormatter; |
15
|
|
|
|
16
|
|
|
public function __construct($name, $title = null, $value = null) |
17
|
|
|
{ |
18
|
|
|
parent::__construct($name, $title, $value); |
19
|
|
|
$this->setAlias(self::ALIAS_NUMERIC); |
20
|
|
|
$this->applyDefaultNumericOptions(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function applyDefaultNumericOptions() |
24
|
|
|
{ |
25
|
|
|
$this->setRighAlign(false); |
26
|
|
|
$this->setAutogroup(true); |
27
|
|
|
$this->setGroupSeparator($this->getCurrencyGroupingSeparator()); |
28
|
|
|
$this->setRadixPoint($this->getCurrencyDecimalSeparator()); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function setValue($value, $data = null) |
32
|
|
|
{ |
33
|
|
|
return parent::setValue($value, $data); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Create a new class for this field |
38
|
|
|
*/ |
39
|
|
|
public function performReadonlyTransformation() |
40
|
|
|
{ |
41
|
|
|
$field = $this->castedCopy(NumericReadonlyField::class); |
42
|
|
|
return $field; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getDigits() |
46
|
|
|
{ |
47
|
|
|
return $this->getConfig('digits'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function setDigits($value) |
51
|
|
|
{ |
52
|
|
|
return $this->setConfig('digits', $value); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getDigitsOptional() |
56
|
|
|
{ |
57
|
|
|
return $this->getConfig('digitsOptional'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setDigitsOptional($value) |
61
|
|
|
{ |
62
|
|
|
return $this->setConfig('digitsOptional', $value); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getEnforceDigitsOnBlur() |
66
|
|
|
{ |
67
|
|
|
return $this->getConfig('enforceDigitsOnBlur'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setEnforceDigitsOnBlur($value) |
71
|
|
|
{ |
72
|
|
|
return $this->setConfig('enforceDigitsOnBlur', $value); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getGroupSize() |
76
|
|
|
{ |
77
|
|
|
return $this->getConfig('groupSize'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setGroupSize($value) |
81
|
|
|
{ |
82
|
|
|
return $this->setConfig('groupSize', $value); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getAutogroup() |
86
|
|
|
{ |
87
|
|
|
return $this->getConfig('autoGroup'); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function setAutogroup($value) |
91
|
|
|
{ |
92
|
|
|
return $this->setConfig('autoGroup', $value); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getAllowMinus() |
96
|
|
|
{ |
97
|
|
|
return $this->getConfig('allowMinus'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function setAllowMinus($value) |
101
|
|
|
{ |
102
|
|
|
return $this->setConfig('allowMinus', $value); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getNegationSymbol() |
106
|
|
|
{ |
107
|
|
|
return $this->getConfig('negationSymbol'); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function setNegationSymbol($value) |
111
|
|
|
{ |
112
|
|
|
return $this->setConfig('negationSymbol', $value); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getIntegerDigits() |
116
|
|
|
{ |
117
|
|
|
return $this->getConfig('integerDigits'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function setIntegerDigits($value) |
121
|
|
|
{ |
122
|
|
|
return $this->setConfig('integerDigits', $value); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function getIntegerOptional() |
126
|
|
|
{ |
127
|
|
|
return $this->getConfig('integerOptional'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function setIntegerOptional($value) |
131
|
|
|
{ |
132
|
|
|
return $this->setConfig('integerOptional', $value); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getPrefix() |
136
|
|
|
{ |
137
|
|
|
return $this->getConfig('prefix'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function setPrefix($value) |
141
|
|
|
{ |
142
|
|
|
return $this->setConfig('prefix', $value); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function getSuffix() |
146
|
|
|
{ |
147
|
|
|
return $this->getConfig('suffix'); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function setSuffix($value) |
151
|
|
|
{ |
152
|
|
|
return $this->setConfig('suffix', $value); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function getDecimalProtect() |
156
|
|
|
{ |
157
|
|
|
return $this->getConfig('decimalProtect'); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function setDecimalProtect($value) |
161
|
|
|
{ |
162
|
|
|
return $this->setConfig('decimalProtect', $value); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function getMin() |
166
|
|
|
{ |
167
|
|
|
return $this->getConfig('min'); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function setMin($value) |
171
|
|
|
{ |
172
|
|
|
return $this->setConfig('min', $value); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function getMax() |
176
|
|
|
{ |
177
|
|
|
return $this->getConfig('max'); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
public function setMax($value) |
181
|
|
|
{ |
182
|
|
|
return $this->setConfig('max', $value); |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|