@@ -24,7 +24,6 @@ class TextInput extends TextBase
2424 public function __construct ($ label = NULL , $ maxLength = NULL )
2525 {
2626 parent ::__construct ($ label );
27- $ this ->control ->type = 'text ' ;
2827 $ this ->control ->maxlength = $ maxLength ;
2928 $ this ->setOption ('type ' , 'text ' );
3029 }
@@ -63,7 +62,7 @@ public function getControl()
6362 foreach ($ this ->getRules () as $ rule ) {
6463 if ($ rule ->isNegative || $ rule ->branch ) {
6564
66- } elseif ($ input ->type === ' text ' && in_array ($ rule ->validator , [Form::EMAIL , Form::URL , Form::INTEGER , Form::FLOAT ], TRUE )) {
65+ } elseif ($ input ->type === NULL && in_array ($ rule ->validator , [Form::EMAIL , Form::URL , Form::INTEGER , Form::FLOAT ], TRUE )) {
6766 static $ types = [Form::EMAIL => 'email ' , Form::URL => 'url ' , Form::INTEGER => 'number ' , Form::FLOAT => 'number ' ];
6867 $ input ->type = $ types [$ rule ->validator ];
6968
@@ -85,7 +84,7 @@ public function getControl()
8584 }
8685
8786 } elseif ($ rule ->validator === Form::PATTERN && is_scalar ($ rule ->arg )
88- && in_array ($ input ->type , ['text ' , 'search ' , 'tel ' , 'url ' , 'email ' , 'password ' ], TRUE )
87+ && in_array ($ input ->type , [NULL , 'text ' , 'search ' , 'tel ' , 'url ' , 'email ' , 'password ' ], TRUE )
8988 ) {
9089 $ input ->pattern = $ rule ->arg ;
9190 }
@@ -96,6 +95,7 @@ public function getControl()
9695 ? $ this ->translate ($ this ->emptyValue )
9796 : $ this ->rawValue ;
9897 }
98+ $ input ->type = $ input ->type ?: 'text ' ;
9999 return $ input ;
100100 }
101101
0 commit comments