1010use Ajax \JsUtils ;
1111use Ajax \common \html \html5 \HtmlInput as HtmlInput5 ;
1212use Ajax \service \Javascript ;
13+ use Ajax \semantic \html \elements \html5 \HtmlDatalist ;
1314
1415class HtmlInput extends HtmlSemDoubleElement {
1516 use IconTrait,TextFieldsTrait,FieldTrait;
1617
17- public function __construct ($ identifier , $ type= "text " , $ value= "" , $ placeholder= "" ) {
18+ public function __construct ($ identifier , $ type = "text " , $ value = "" , $ placeholder = "" ) {
1819 parent ::__construct ("div- " . $ identifier , "div " , "ui input " );
19- $ this ->_identifier =$ identifier ;
20- $ this ->_libraryId =$ identifier ;
21- $ this ->content =[ "field " => new HtmlInput5 ($ identifier , $ type , $ value , $ placeholder ) ];
22- $ this ->_states =[ State::DISABLED ,State::FOCUS ,State::ERROR ];
23- $ this ->_variations =[ Variation::TRANSPARENT ];
20+ $ this ->_identifier = $ identifier ;
21+ $ this ->_libraryId = $ identifier ;
22+ $ this ->content = [
23+ "field " => new HtmlInput5 ($ identifier , $ type , $ value , $ placeholder )
24+ ];
25+ $ this ->_states = [
26+ State::DISABLED ,
27+ State::FOCUS ,
28+ State::ERROR
29+ ];
30+ $ this ->_variations = [
31+ Variation::TRANSPARENT
32+ ];
2433 }
2534
2635 public function getField () {
@@ -31,27 +40,35 @@ public function getDataField() {
3140 return $ this ->content ["field " ];
3241 }
3342
34- public static function outline ($ identifier , $ icon , $ value= "" , $ placeholder= "" ) {
35- $ result= new HtmlInput ($ identifier , "text " , $ value , $ placeholder );
43+ public static function outline ($ identifier , $ icon , $ value = "" , $ placeholder = "" ) {
44+ $ result = new HtmlInput ($ identifier , "text " , $ value , $ placeholder );
3645 $ result ->addToProperty ("class " , "transparent " );
3746 $ result ->addIcon ($ icon )->setOutline ();
3847 return $ result ;
3948 }
4049
4150 public function run (JsUtils $ js ) {
42- $ result =parent ::run ($ js );
43- $ result ->attach ("# " . $ this ->getDataField ()->getIdentifier ());
51+ $ result = parent ::run ($ js );
52+ $ result ->attach ("# " . $ this ->getDataField ()
53+ ->getIdentifier ());
4454 return $ result ;
4555 }
4656
47- public function setTransparent (){
57+ public function setTransparent () {
4858 return $ this ->addToProperty ("class " , "transparent " );
4959 }
50-
51- public function compile_once (\Ajax \JsUtils $ js = NULL , &$ view = NULL ){
52- parent ::compile_once ($ js ,$ view );
53- if (isset ($ this ->content ['file ' ])){
60+
61+ public function compile_once (\Ajax \JsUtils $ js = NULL , &$ view = NULL ) {
62+ parent ::compile_once ($ js , $ view );
63+ if (isset ($ this ->content ['file ' ])) {
5464 $ this ->onCreate (Javascript::fileUploadBehavior ($ this ->identifier ));
5565 }
5666 }
67+
68+ public function addDataList ($ items ) {
69+ $ dl = new HtmlDatalist ('list- ' . $ this ->identifier );
70+ $ dl ->addItems ($ items );
71+ $ this ->getDataField ()->setProperty ('list ' , $ dl ->getIdentifier ());
72+ $ this ->getDataField ()->wrap ($ dl );
73+ }
5774}
0 commit comments