11<?php
2-
32namespace Ajax \common \html \html5 ;
43
54use Ajax \common \html \HtmlSingleElement ;
65use Ajax \service \JString ;
76use Ajax \JsUtils ;
87
98class HtmlInput extends HtmlSingleElement {
9+
1010 protected $ _placeholder ;
11- public function __construct ($ identifier ,$ type ="text " ,$ value =NULL ,$ placeholder =NULL ) {
11+
12+ public function __construct ($ identifier , $ type = "text " , $ value = NULL , $ placeholder = NULL ) {
1213 parent ::__construct ($ identifier , "input " );
1314 $ this ->setProperty ("name " , $ identifier );
1415 $ this ->setValue ($ value );
@@ -17,28 +18,34 @@ public function __construct($identifier,$type="text",$value=NULL,$placeholder=NU
1718 }
1819
1920 public function setValue ($ value ) {
20- if (isset ($ value ))
21- $ this ->setProperty ("value " , $ value );
21+ if (isset ($ value ))
22+ $ this ->setProperty ("value " , $ value );
2223 return $ this ;
2324 }
2425
2526 public function setInputType ($ value ) {
2627 return $ this ->setProperty ("type " , $ value );
2728 }
2829
29- public function setPlaceholder ($ value ){
30- if (JString::isNotNull ($ value ))
31- $ this ->_placeholder =$ value ;
30+ public function forceValue ($ value = 'true ' ) {
31+ $ this ->wrap ('<input type="hidden" value="false" name=" ' . $ this ->identifier . '"/> ' );
32+ $ this ->setValue ($ value );
33+ return $ this ;
34+ }
35+
36+ public function setPlaceholder ($ value ) {
37+ if (JString::isNotNull ($ value ))
38+ $ this ->_placeholder = $ value ;
3239 return $ this ;
3340 }
3441
35- public function compile (JsUtils $ js= NULL ,&$ view= NULL ){
36- $ value= $ this ->_placeholder ;
37- if (JString::isNull ($ value )){
38- if (JString::isNotNull ($ this ->getProperty ("name " )))
39- $ value= \ucfirst ($ this ->getProperty ("name " ));
42+ public function compile (JsUtils $ js = NULL , &$ view = NULL ) {
43+ $ value = $ this ->_placeholder ;
44+ if (JString::isNull ($ value )) {
45+ if (JString::isNotNull ($ this ->getProperty ("name " )))
46+ $ value = \ucfirst ($ this ->getProperty ("name " ));
4047 }
4148 $ this ->setProperty ("placeholder " , $ value );
42- return parent ::compile ($ js ,$ view );
49+ return parent ::compile ($ js , $ view );
4350 }
4451}
0 commit comments