Skip to content

Commit

Permalink
SelectOption: Add method getLabel() and change method setLabel()
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Sep 2, 2022
1 parent 0285e95 commit 72434e5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/FormElement/SelectOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class SelectOption extends BaseHtmlElement
/** @var mixed */
protected $value;

/** @var string */
protected $label;

/**
* SelectOption constructor.
* @param string|null $value
Expand All @@ -19,22 +22,29 @@ class SelectOption extends BaseHtmlElement
public function __construct($value = null, $label = null)
{
$this->value = $value;
$this->add($label);
$this->setLabel($label);

$this->getAttributes()->registerAttributeCallback('value', [$this, 'getValue']);
}

/**
* @param $label
*
* @return $this
*/
public function setLabel($label)
{
$this->setContent($label);
$this->label = $label;
$this->add($label);

return $this;
}

public function getLabel()
{
return $this->label;
}

/**
* @return string
*/
Expand Down

0 comments on commit 72434e5

Please sign in to comment.