diff --git a/phpxpress/examples/dropdown.php b/phpxpress/examples/dropdown.php new file mode 100644 index 0000000..12215d1 --- /dev/null +++ b/phpxpress/examples/dropdown.php @@ -0,0 +1,18 @@ + + + Dropdown example + + + + setTitle("Title"); + $dropdown->setDataSource(array("AA" => "#" , "BB" => "#")); + $dropdown->setSize("large"); + $dropdown->draw(); + ?> + + \ No newline at end of file diff --git a/phpxpress/phpxpress/dropdown.php b/phpxpress/phpxpress/dropdown.php new file mode 100644 index 0000000..032e927 --- /dev/null +++ b/phpxpress/phpxpress/dropdown.php @@ -0,0 +1,64 @@ + + link + public function setDataSource(Array $datasource){ + $this->datasource = $datasource; + } + + public function setTitle($title){ + $this->title = $title; + } + + public function setColor($color){ + $this->color = Code::bootstrapColors($color); + } + + public function setSize($size){ + if($size == "default") + $this->size = NULL; + + else if($size == "large") + $this->size = "btn-lg"; + + else if($size == "small") + $this->size = "btn-sm"; + + else + throw new InvalidArgumentException('Parameter size must be either default, large or small.'); + + + } + + public function draw(){ + + $btnClass = 'btn btn-' . $this->color . ' dropdown-toggle'; + if(isset($this->size)){ + $btnClass .= ' ' . $this->size; + } + + echo ''; + } + } +?> \ No newline at end of file