10
10
use Ajax \JsUtils ;
11
11
use Ajax \common \html \html5 \HtmlInput as HtmlInput5 ;
12
12
use Ajax \service \Javascript ;
13
+ use Ajax \semantic \html \elements \html5 \HtmlDatalist ;
13
14
14
15
class HtmlInput extends HtmlSemDoubleElement {
15
16
use IconTrait,TextFieldsTrait,FieldTrait;
16
17
17
- public function __construct ($ identifier , $ type= "text " , $ value= "" , $ placeholder= "" ) {
18
+ public function __construct ($ identifier , $ type = "text " , $ value = "" , $ placeholder = "" ) {
18
19
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
+ ];
24
33
}
25
34
26
35
public function getField () {
@@ -31,27 +40,35 @@ public function getDataField() {
31
40
return $ this ->content ["field " ];
32
41
}
33
42
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 );
36
45
$ result ->addToProperty ("class " , "transparent " );
37
46
$ result ->addIcon ($ icon )->setOutline ();
38
47
return $ result ;
39
48
}
40
49
41
50
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 ());
44
54
return $ result ;
45
55
}
46
56
47
- public function setTransparent (){
57
+ public function setTransparent () {
48
58
return $ this ->addToProperty ("class " , "transparent " );
49
59
}
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 ' ])) {
54
64
$ this ->onCreate (Javascript::fileUploadBehavior ($ this ->identifier ));
55
65
}
56
66
}
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
+ }
57
74
}
0 commit comments