1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\collections\form; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\collections\form\HtmlFormField; |
6
|
|
|
use Ajax\semantic\html\modules\HtmlDropdown; |
7
|
|
|
|
8
|
|
|
class HtmlFormDropdown extends HtmlFormField { |
9
|
|
|
|
10
|
|
|
public function __construct($identifier,$items=array(), $label=NULL,$value="",$multiple=false,$associative=true) { |
11
|
|
|
parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
12
|
|
|
$this->_identifier=$identifier; |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
public function setItems($items){ |
16
|
|
|
return $this->getField()->setItems($items); |
17
|
|
|
} |
18
|
|
|
public function addItem($item,$value=NULL,$image=NULL){ |
19
|
|
|
return $this->getField()->addItem($item,$value,$image); |
20
|
|
|
} |
21
|
|
|
public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value="",$associative=true){ |
22
|
|
|
return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return HtmlDropdown |
27
|
|
|
*/ |
28
|
|
|
public function getDataField(){ |
29
|
|
|
return $this->getField()->getInput(); |
30
|
|
|
} |
31
|
|
|
public function asSelect($name=NULL,$multiple=false,$selection=true){ |
32
|
|
|
$this->getField()->asSelect($name,$multiple,$selection); |
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param boolean $floating |
38
|
|
|
* @return HtmlDropdown |
39
|
|
|
*/ |
40
|
|
|
public function asButton($floating=false){ |
41
|
|
|
$field=$this->content["field"]; |
42
|
|
|
$label=$this->content["label"]; |
43
|
|
|
$field->addContent($label); |
44
|
|
|
$this->content=["field"=>$field]; |
45
|
|
|
$this->content["field"]->asButton($floating); |
46
|
|
|
return $this->content["field"]; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|