value = $value === '' ? null : $value;
$this->label = $label;
$this->getAttributes()->registerAttributeCallback('value', [$this, 'getValueAttribute']);
}
/**
* Set the label of the option
*
* @param string $label
*
* @return $this
*/
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
/**
* Get the label of the option
*
* @return string
*/
public function getLabel(): string
{
return $this->label;
}
/**
* Get the value of the option
*
* @return string|int|null
*/
public function getValue()
{
return $this->value;
}
/**
* Callback for the value attribute
*
* @return mixed
*/
public function getValueAttribute()
{
return (string) $this->getValue();
}
protected function assemble()
{
$this->setContent($this->getLabel());
}
}