Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / htmlform / HTMLTextField.php
blob88df49dbf5d566e1d1e2d19dfe7d08bf49420340
1 <?php
3 class HTMLTextField extends HTMLFormField {
4 function getSize() {
5 return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
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();
16 if ( $this->mClass !== '' ) {
17 $attribs['class'] = $this->mClass;
20 # @todo Enforce pattern, step, required, readonly on the server side as
21 # well
22 $allowedParams = array(
23 'type',
24 'min',
25 'max',
26 'pattern',
27 'title',
28 'step',
29 'placeholder',
30 'list',
31 'maxlength',
32 'tabindex',
33 'disabled',
34 'required',
35 'autofocus',
36 'multiple',
37 'readonly'
40 $attribs += $this->getAttributes( $allowedParams );
42 # Extract 'type'
43 $type = isset( $attribs['type'] ) ? $attribs['type'] : 'text';
44 unset( $attribs['type'] );
46 # Implement tiny differences between some field variants
47 # here, rather than creating a new class for each one which
48 # is essentially just a clone of this one.
49 if ( isset( $this->mParams['type'] ) ) {
50 switch ( $this->mParams['type'] ) {
51 case 'int':
52 $type = 'number';
53 break;
54 case 'float':
55 $type = 'number';
56 $attribs['step'] = 'any';
57 break;
58 # Pass through
59 case 'email':
60 case 'password':
61 case 'file':
62 case 'url':
63 $type = $this->mParams['type'];
64 break;
68 return Html::input( $this->mName, $value, $type, $attribs );