Allow Select options to be disabled

This commit is contained in:
Stephen Abello
2021-03-03 15:57:43 +01:00
parent c2c69d9f43
commit ad0fdfe921
3 changed files with 24 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ class SelectOption extends UIBlock
protected $sLabel;
/** @var bool */
protected $bSelected;
/** @var bool */
protected $bDisabled;
/**
* @return string
@@ -76,6 +78,25 @@ class SelectOption extends UIBlock
{
$this->bSelected = $bSelected;
return $this;
}
/**
* @return bool
*/
public function IsDisabled(): bool
{
return $this->bDisabled;
}
/**
* @param bool $bDisabled
*
* @return SelectOption
*/
public function SetDisabled(bool $bDisabled): SelectOption
{
$this->bDisabled = $bDisabled;
return $this;
}
}

View File

@@ -21,7 +21,8 @@ class SelectOptionUIBlockFactory extends AbstractUIBlockFactory
$oInput->SetValue($sValue)
->SetLabel($sLabel)
->SetSelected($bSelected);
->SetSelected($bSelected)
->SetDisabled(false);
return $oInput;
}

View File

@@ -1,3 +1,3 @@
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
<option id="{{ oUIBlock.GetId() }}" value="{{ oUIBlock.GetValue() }}" {% if oUIBlock.IsSelected() %}selected{% endif %}>{{ oUIBlock.GetLabel() }}</option>
<option id="{{ oUIBlock.GetId() }}" value="{{ oUIBlock.GetValue() }}" {% if oUIBlock.IsSelected() %}selected{% endif %} {% if oUIBlock.IsDisabled() %}disabled{% endif %}>{{ oUIBlock.GetLabel() }}</option>