N°8772 - dynamic form

This commit is contained in:
Benjamin Dalsass
2025-11-12 17:09:40 +01:00
parent 3d2485a004
commit 5cacfcb754
18 changed files with 320 additions and 296 deletions

View File

@@ -11,6 +11,7 @@ use Combodo\iTop\Forms\Block\FormBlockException;
use Combodo\iTop\Forms\Block\IO\Converter\StringToAttributeConverter;
use Combodo\iTop\Forms\Block\IO\Format\AttributeIOFormat;
use Combodo\iTop\Forms\Block\IO\Format\ClassIOFormat;
use Combodo\iTop\Forms\Block\IO\Format\RawFormat;
use CoreException;
use MetaModel;
@@ -52,10 +53,17 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
/** @inheritdoc */
public function UpdateDynamicOptions(string $sEventType = null): void
{
$oValue = $this->GetInput(self::INPUT_CLASS_NAME)->GetValue($sEventType);
$oClass = $this->GetInput(self::INPUT_CLASS_NAME)->GetValue($sEventType);
$aAttributeCodes = MetaModel::GetAttributesList($oValue);
$this->aDynamicOptions['choices'] = array_combine($aAttributeCodes, $aAttributeCodes);
$aAttributeCodes = MetaModel::GetAttributesList($oClass);
$aAttributes = [];
foreach ($aAttributeCodes as $sAttributeCode){
$oAttribute = MetaModel::GetAttributeDef(strval($oClass), $sAttributeCode);
$aAttributes[$oAttribute->GetLabel()] = $sAttributeCode;
}
$this->aDynamicOptions['choices'] = $aAttributes;
}
}