form input

This commit is contained in:
Benjamin Dalsass
2025-12-04 15:25:52 +01:00
parent 9c540b6227
commit 3503805fe1
20 changed files with 261 additions and 53 deletions

View File

@@ -7,7 +7,10 @@
namespace Combodo\iTop\Forms\Block\DataModel;
use Combodo\iTop\Core\AttributeDefinition\AttributeEnum;
use Combodo\iTop\Forms\Block\FormBlockException;
use Combodo\iTop\Forms\IO\Format\AttributeTypeArrayIOFormat;
use Combodo\iTop\Forms\IO\Format\AttributeTypeIOFormat;
use Combodo\iTop\Forms\Register\RegisterException;
use Combodo\iTop\Service\DependencyInjection\DIException;
use Combodo\iTop\Service\DependencyInjection\DIService;
@@ -29,6 +32,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
{
// inputs
public const INPUT_CLASS_NAME = 'input_class_name';
public const INPUT_ATTRIBUTE_TYPE = 'input_attribute_type';
// outputs
public const OUTPUT_ATTRIBUTE = 'output_attribute';
@@ -46,6 +50,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
{
parent::RegisterIO($oIORegister);
$oIORegister->AddInput(self::INPUT_CLASS_NAME, ClassIOFormat::class);
$oIORegister->AddInput(self::INPUT_ATTRIBUTE_TYPE, AttributeTypeIOFormat::class);
$oIORegister->AddOutput(self::OUTPUT_ATTRIBUTE, AttributeIOFormat::class);
}
@@ -62,6 +67,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
// Get class name
$sClass = strval($this->GetInputValue(self::INPUT_CLASS_NAME));
$sAttType = $this->GetInputValue(self::INPUT_ATTRIBUTE_TYPE)->sAttributeType;
// Empty class => no choices
if (utils::IsNullOrEmptyString($sClass)) {
@@ -71,7 +77,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
/** List attributes @var ModelReflection $oModelReflection */
$oModelReflection = DIService::GetInstance()->GetService('ModelReflection');
$aAttributeCodes = array_keys($oModelReflection->ListAttributes($sClass));
$aAttributeCodes = array_keys($oModelReflection->ListAttributes($sClass, $sAttType));
$aAttributes = [];
foreach ($aAttributeCodes as $sAttCode) {
$sLabel = $oModelReflection->GetLabel($sClass, $sAttCode);