-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHTML5NumericField.php
75 lines (65 loc) · 1.33 KB
/
HTML5NumericField.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
<?php
class HTML5NumericField extends NumericField {
static $extensions = array(
'HTML5FieldsDecorator'
);
// Value for the type attribute
protected $type = 'number';
// If this field is required, the HTML5 required attribute will be set
protected $requried = false;
// Regular expression validation
protected $pattern;
// Min and max HTML5 attributes
protected $min;
protected $max;
/**
* Called by HTML5FieldsDecorator::defaultField()
* Adds non-default attributes
*
* @param array
* @return array
*/
public function amendAttributes( $attributes ) {
return array(
'min' => $this->min,
'max' => $this->max
);
}
/**
* @see HTML5FieldsDecorator::defaultField()
*/
function Field() {
return $this->defaultField();
}
/**
* @see FormField::FieldHolder()
*/
public function FieldHolder() {
return $this->defaultFieldHolder();
}
/**
* Set the min variable
*
* @param int $min
*/
public function setMin( $min ) {
$this->min = $min;
}
/**
* Set the man variable
*
* @param int $max
*/
public function setMax( $max ) {
$this->max = $max;
}
/**
* Set the pattern attribute for in-browser regular expression validation
* Regular expressions have an implied ^(:? and )$
*
* @param string $regex
*/
public function setPattern( $regex ) {
$this->owner->pattern = $regex;
}
}