mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 06:28:46 +02:00
N°8771 - Add Symfony form component to iTop core
- IO debug
This commit is contained in:
@@ -11,7 +11,6 @@ use Combodo\iTop\Forms\Block\IO\Format\AttributeIOFormat;
|
||||
use Combodo\iTop\Forms\Block\IO\Format\ClassIOFormat;
|
||||
use Combodo\iTop\Forms\Block\IO\FormInput;
|
||||
use Combodo\iTop\Forms\Block\IO\FormOutput;
|
||||
use Combodo\iTop\Forms\Converter\OqlToClassConverter;
|
||||
use Combodo\iTop\Forms\Converter\StringToAttributeConverter;
|
||||
|
||||
/**
|
||||
@@ -34,9 +33,25 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
$this->AddInput(new FormInput(self::INPUT_CLASS_NAME, ClassIOFormat::class));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function InitOutputs(): void
|
||||
{
|
||||
parent::InitOutputs();
|
||||
$this->AddOutput(new FormOutput(self::OUTPUT_ATTRIBUTE, AttributeIOFormat::class, new StringToAttributeConverter()));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function GetOptions(): array
|
||||
{
|
||||
$aOptions = parent::GetOptions();
|
||||
|
||||
$oBinding = $this->GetInput(self::INPUT_CLASS_NAME)->GetBinding();
|
||||
$oConnectionValue = $oBinding->oOutput->Value();
|
||||
|
||||
$aAttributeCodes = \MetaModel::GetAttributesList($oConnectionValue);
|
||||
$aAttributeCodes = array_combine($aAttributeCodes, $aAttributeCodes) ;
|
||||
$aOptions['choices'] = $aAttributeCodes;
|
||||
|
||||
return $aOptions;
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,15 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
|
||||
public const INPUT_ATTRIBUTE = 'attribute';
|
||||
|
||||
/** @inheritdoc */
|
||||
public function InitOptions(array &$aOptions = []): void
|
||||
public function InitOptions(array &$aOptions = []): array
|
||||
{
|
||||
$aOptions['multiple'] = true;
|
||||
$aOptions['attr'] = [
|
||||
'size' => 10,
|
||||
'style' => 'height: auto;'
|
||||
];
|
||||
|
||||
return $aOptions;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@@ -36,4 +42,22 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
|
||||
$this->AddInput(new FormInput(self::INPUT_ATTRIBUTE, AttributeIOFormat::class));
|
||||
}
|
||||
|
||||
public function GetOptions(): array
|
||||
{
|
||||
$aOptions = parent::GetOptions();
|
||||
|
||||
$oBindingClassName = $this->GetInput(self::INPUT_CLASS_NAME)->GetBinding();
|
||||
$oClassName = $oBindingClassName->oOutput->Value();
|
||||
|
||||
$oBindingAttribute = $this->GetInput(self::INPUT_ATTRIBUTE)->GetBinding();
|
||||
$oAttribute = $oBindingAttribute->oOutput->Value();
|
||||
|
||||
$oAttDef = \MetaModel::GetAttributeDef(strval($oClassName), strval($oAttribute));
|
||||
$aValues = $oAttDef->GetAllowedValues();
|
||||
|
||||
$aOptions['choices'] = array_flip($aValues);
|
||||
|
||||
return $aOptions;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user