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, new StringToAttributeConverter()); } /** * @param \Combodo\iTop\Forms\Register\OptionsRegister $oOptionsRegister * * @throws \Combodo\iTop\Service\DependencyInjection\DIException * @throws \Combodo\iTop\Forms\Block\FormBlockException * @throws \Combodo\iTop\Forms\Register\RegisterException */ public function UpdateOptions(OptionsRegister $oOptionsRegister): void { parent::UpdateOptions($oOptionsRegister); $sClass = strval($this->GetInputValue(self::INPUT_CLASS_NAME)); if (utils::IsNullOrEmptyString($sClass)) { $oOptionsRegister->SetOption('choices', []); return; } /** @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); } }