AddInput(self::INPUT_CLASS_NAME, ClassIOFormat::class); } /** * @param \Combodo\iTop\Forms\Register\OptionsRegister $oOptionsRegister * * @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)); $aFunctionAttributes = AttributeChoiceFormBlock::ListAttributeCodesByCategory($sClass, 'numeric'); $aFunctions = $this->GetAllowedFunctions($aFunctionAttributes); $oOptionsRegister->SetOption('choices', $aFunctions); } /** * @param array $aFunctionAttributes * * @return array */ protected function GetAllowedFunctions(array $aFunctionAttributes): array { $aFunctions = []; $aFunctions[Dict::S('UI:GroupBy:count')] = 'count'; if (!empty($aFunctionAttributes)) { $aFunctions[Dict::S('UI:GroupBy:sum')] = 'sum'; $aFunctions[Dict::S('UI:GroupBy:avg')] = 'avg'; $aFunctions[Dict::S('UI:GroupBy:min')] = 'min'; $aFunctions[Dict::S('UI:GroupBy:max')] = 'max'; } return $aFunctions; } }