Merge "Include action in permission error messages"
[lhc/web/wiklou.git] / includes / htmlform / HTMLTextField.php
1 <?php
2
3 class HTMLTextField extends HTMLFormField {
4 function getSize() {
5 return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
6 }
7
8 function getInputHTML( $value ) {
9 $attribs = array(
10 'id' => $this->mID,
11 'name' => $this->mName,
12 'size' => $this->getSize(),
13 'value' => $value,
14 ) + $this->getTooltipAndAccessKey();
15
16 if ( $this->mClass !== '' ) {
17 $attribs['class'] = $this->mClass;
18 }
19
20 # @todo Enforce pattern, step, required, readonly on the server side as
21 # well
22 $allowedParams = array(
23 'min',
24 'max',
25 'pattern',
26 'title',
27 'step',
28 'placeholder',
29 'list',
30 'maxlength',
31 'tabindex',
32 'disabled',
33 'required',
34 'autofocus',
35 'multiple',
36 'readonly'
37 );
38
39 $attribs += $this->getAttributes( $allowedParams );
40
41 # Implement tiny differences between some field variants
42 # here, rather than creating a new class for each one which
43 # is essentially just a clone of this one.
44 $type = 'text';
45 if ( isset( $this->mParams['type'] ) ) {
46 switch ( $this->mParams['type'] ) {
47 case 'int':
48 $type = 'number';
49 break;
50 case 'float':
51 $type = 'number';
52 $attribs['step'] = 'any';
53 break;
54 # Pass through
55 case 'email':
56 case 'password':
57 case 'file':
58 case 'url':
59 $type = $this->mParams['type'];
60 break;
61 }
62 }
63 return Html::input( $this->mName, $value, $type, $attribs );
64 }
65 }