2 class HTMLTextField
extends HTMLFormField
{
4 return isset( $this->mParams
[ 'size' ] ) ?
$this->mParams
[ 'size' ] : 45;
7 function getInputHTML( $value ) {
10 'name' => $this->mName
,
11 'size' => $this->getSize(),
13 ) +
$this->getTooltipAndAccessKey();
15 if ( $this->mClass
!== '' ) {
16 $attribs[ 'class' ] = $this->mClass
;
19 if ( ! empty( $this->mParams
[ 'disabled' ] ) ) {
20 $attribs[ 'disabled' ] = 'disabled';
23 # TODO: Enforce pattern, step, required, readonly on the server side as
25 $allowedParams = array(
35 foreach ( $allowedParams as $param ) {
36 if ( isset( $this->mParams
[ $param ] ) ) {
37 $attribs[ $param ] = $this->mParams
[ $param ];
41 foreach ( array( 'required', 'autofocus', 'multiple', 'readonly' ) as $param ) {
42 if ( isset( $this->mParams
[ $param ] ) ) {
43 $attribs[ $param ] = '';
47 # Implement tiny differences between some field variants
48 # here, rather than creating a new class for each one which
49 # is essentially just a clone of this one.
50 if ( isset( $this->mParams
[ 'type' ] ) ) {
51 switch( $this->mParams
[ 'type' ] ) {
53 $attribs[ 'type' ] = 'email';
56 $attribs[ 'type' ] = 'number';
59 $attribs[ 'type' ] = 'number';
60 $attribs[ 'step' ] = 'any';
65 $attribs[ 'type' ] = $this->mParams
[ 'type' ];
70 return Html
::element( 'input', $attribs );