@@ -28,11 +28,15 @@ public function __construct($identifier, $value="", $items=array(),$associative=
2828 parent ::__construct ($ identifier , "div " );
2929 $ this ->_template =include dirname (__FILE__ ).'/../templates/tplDropdown.php ' ;
3030 $ this ->setProperty ("class " , "ui dropdown " );
31- $ content =new HtmlSemDoubleElement ("text- " .$ this ->identifier ,"div " );
32- $ content ->setClass ("text " );
33- $ this ->setValue ($ value );
34- $ content ->wrap ("" ,new HtmlIcon ("" , "dropdown " ));
35- $ this ->content =array ($ content );
31+ $ content =[];
32+ if (isset ($ value )){
33+ $ text =new HtmlSemDoubleElement ("text- " .$ this ->identifier ,"div " );
34+ $ text ->setClass ("text " );
35+ $ content =[$ text ];
36+ $ this ->setValue ($ value );
37+ }
38+ $ content ["arrow " ]=new HtmlIcon ("" , "dropdown " );
39+ $ this ->content =$ content ;
3640 $ this ->tagName ="div " ;
3741 $ this ->_associative =$ associative ;
3842 $ this ->addItems ($ items );
@@ -53,6 +57,7 @@ public function addItem($item,$value=NULL,$image=NULL,$description=NULL){
5357 }
5458
5559 public function addIcon ($ icon ,$ before =true ,$ labeled =false ){
60+ $ this ->removeArrow ();
5661 $ this ->addIconP ($ icon ,$ before ,$ labeled );
5762 return $ this ->getElementById ("text- " .$ this ->identifier , $ this ->content )->setWrapAfter ("" );
5863 }
@@ -79,6 +84,13 @@ public function insertItem($item,$position=0){
7984 return $ itemO ;
8085 }
8186
87+ protected function removeArrow (){
88+ if (\sizeof ($ this ->content )>1 ){
89+ unset($ this ->content ["arrow " ]);
90+ $ this ->content =\array_values ($ this ->content );
91+ }
92+ }
93+
8294 protected function beforeAddItem ($ item ,$ value =NULL ,$ image =NULL ,$ description =NULL ){
8395 $ itemO =$ item ;
8496 if (\is_array ($ item )){
@@ -205,6 +217,7 @@ public function setSimple(){
205217 }
206218
207219 public function asButton ($ floating =false ){
220+ $ this ->removeArrow ();
208221 if ($ floating )
209222 $ this ->addToProperty ("class " , "floating " );
210223 $ this ->removePropertyValue ("class " , "selection " );
@@ -308,5 +321,7 @@ public function compile(JsUtils $js=NULL, &$view=NULL) {
308321 public function getInput () {
309322 return $ this ->input ;
310323 }
311-
324+ public function addAction ($ action , $ direction =Direction::RIGHT , $ icon =NULL , $ labeled =false ) {
325+ return $ this ->_addAction ($ this , $ action ,$ direction ,$ icon ,$ labeled );
326+ }
312327}
0 commit comments