SetOption('placeholder', 'Select an attribute...'); } /** @inheritdoc */ protected function RegisterIO(IORegister $oIORegister): void { parent::RegisterIO($oIORegister); $oIORegister->AddInput(self::INPUT_CLASS_NAME, ClassIOFormat::class); $oIORegister->AddOutput(self::OUTPUT_ATTRIBUTE, AttributeIOFormat::class); } /** * @inheritdoc * * @throws DIException * @throws FormBlockException * @throws RegisterException */ public function UpdateOptions(OptionsRegister $oOptionsRegister): void { parent::UpdateOptions($oOptionsRegister); // Get class name $sClass = strval($this->GetInputValue(self::INPUT_CLASS_NAME)); // Empty class => no choices if (utils::IsNullOrEmptyString($sClass)) { $oOptionsRegister->SetOption('choices', []); return; } /** List attributes @var ModelReflection $oModelReflection */ $oModelReflection = DIService::GetInstance()->GetService('ModelReflection'); $aAttributeCodes = array_keys($oModelReflection->ListAttributes($sClass)); $aAttributes = []; foreach ($aAttributeCodes as $sAttCode) { $sLabel = $oModelReflection->GetLabel($sClass, $sAttCode); $aAttributes[$sLabel] = $sAttCode; } $oOptionsRegister->SetOption('choices', $aAttributes); } }