diff options
Diffstat (limited to 'vendor/ipl/html/src/FormElement/SelectOption.php')
-rw-r--r-- | vendor/ipl/html/src/FormElement/SelectOption.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/ipl/html/src/FormElement/SelectOption.php b/vendor/ipl/html/src/FormElement/SelectOption.php new file mode 100644 index 0000000..d0dbf7c --- /dev/null +++ b/vendor/ipl/html/src/FormElement/SelectOption.php @@ -0,0 +1,45 @@ +<?php + +namespace ipl\Html\FormElement; + +use ipl\Html\BaseHtmlElement; + +class SelectOption extends BaseHtmlElement +{ + protected $tag = 'option'; + + /** @var mixed */ + protected $value; + + /** + * SelectOption constructor. + * @param string|null $value + * @param string|null $label + */ + public function __construct($value = null, $label = null) + { + $this->value = $value; + $this->add($label); + + $this->getAttributes()->registerAttributeCallback('value', [$this, 'getValue']); + } + + /** + * @param $label + * @return $this + */ + public function setLabel($label) + { + $this->setContent($label); + + return $this; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } +} |