N°8772 - compilation of choices values

This commit is contained in:
Eric Espie
2025-12-15 17:15:07 +01:00
parent a77e54c8cb
commit 2530d59e08
7 changed files with 59 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ abstract class AbstractValueType
protected array $aInputs = [];
protected array $aOutputs = [];
protected array $aInputValues = [];
protected array $aFormBlockOptionsForPHP = [];
public function InitFromDomNode(DesignElement $oDomNode): void
{
@@ -40,6 +41,11 @@ abstract class AbstractValueType
}
}
public function GetFormBlockOptions(): array
{
return $this->aFormBlockOptionsForPHP;
}
public function GetInputValues(): array
{
return $this->aInputValues;

View File

@@ -7,8 +7,9 @@
namespace Combodo\iTop\PropertyTree\ValueType;
use Combodo\iTop\DesignElement;
use Combodo\iTop\Forms\Block\Base\ChoiceFormBlock;
use Combodo\iTop\Forms\Block\Base\FormBlock;
use utils;
/**
* @since 3.3.0
@@ -19,4 +20,23 @@ class ValueTypeChoice extends AbstractValueType
{
return ChoiceFormBlock::class;
}
public function InitFromDomNode(DesignElement $oDomNode): void
{
parent::InitFromDomNode($oDomNode);
$sChoices = "[\n";
foreach ($oDomNode->GetNodes('values/value') as $oValueNode) {
/** @var DesignElement $oValueNode */
$sValue = utils::QuoteForPHP($oValueNode->GetAttribute('id'));
$sLabel = utils::QuoteForPHP($oValueNode->GetChildText('label'));
$sChoices .= <<<PHP
\Dict::S($sLabel) => $sValue,
PHP;
}
$sChoices .= "\t\t\t]";
$this->aFormBlockOptionsForPHP['choices'] = $sChoices;
}
}