{"record":{"id":"669675a47f07d062","repo":"octobercms/october","slug":"checkbox-and-radiobutton-dropdown-menu-items-canno","errorCode":null,"errorMessage":"Checkbox and radiobutton dropdown menu items cannot have icons","messagePattern":"Checkbox and radiobutton dropdown menu items cannot have icons","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/vuecomponents/dropdownmenu/ItemDefinition.php","lineNumber":141,"sourceCode":"    }\n\n    /**\n     * setDisabled\n     */\n    public function setDisabled(bool $value)\n    {\n        $this->disabled = $value;\n\n        return $this;\n    }\n\n    /**\n     * setIcon\n     */\n    public function setIcon(string $value)\n    {\n        if (in_array($this->type, [self::TYPE_CHECKBOX, self::TYPE_RADIOBUTTON])) {\n            throw new SystemException('Checkbox and radiobutton dropdown menu items cannot have icons');\n        }\n\n        $this->icon = $value;\n\n        return $this;\n    }\n\n    /**\n     * setChecked\n     */\n    public function setChecked(bool $value)\n    {\n        $this->checked = $value;\n    }\n\n    /**\n     * addItem\n     */","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/vuecomponents/dropdownmenu/ItemDefinition.php#L123-L159","documentation":"ItemDefinition::setIcon() rejects icons on checkbox and radiobutton items: those types render a checked/unchecked state glyph instead of an icon, and the menu layout has no slot for both. The PHP-side guard fails fast so an invalid menu never reaches the browser — the frontend enforces the mirror rule at render time (see the dropdownmenu sheet check).","triggerScenarios":"Calling setIcon('icon-copy') on an item created as ItemDefinition::TYPE_CHECKBOX or ItemDefinition::TYPE_RADIOBUTTON; menu-builder loops that call setIcon on every item regardless of type.","commonSituations":"A generic item factory applying icons from config to all items including stateful ones; converting a normal menu item to a checkbox item and forgetting to drop the icon.","solutions":["Only call setIcon() for non-stateful types (link, button, submenu).","If the icon matters more than the check state, keep the item a plain type instead of checkbox/radiobutton.","Filter icons out when building checkbox/radio items from shared configuration."],"exampleFix":"// before\n$item = (new ItemDefinition(ItemDefinition::TYPE_CHECKBOX, 'Enabled', 'toggle'))\n    ->setIcon('icon-check');\n\n// after - stateful items render their own glyph\n$item = new ItemDefinition(ItemDefinition::TYPE_CHECKBOX, 'Enabled', 'toggle');\n\n// or keep the icon by using a plain item\n$item = (new ItemDefinition(ItemDefinition::TYPE_BUTTON, 'Enabled', 'toggle'))\n    ->setIcon('icon-check');","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function itemCanHaveIcon($item): bool\n{\n    return !in_array(\n        $item->type,\n        [ItemDefinition::TYPE_CHECKBOX, ItemDefinition::TYPE_RADIOBUTTON],\n        true\n    );\n}\n\n// usage in a menu builder\nif ($icon && itemCanHaveIcon($item)) {\n    $item->setIcon($icon);\n}","tryCatchPattern":null,"preventionTips":["Apply icons conditionally in menu builders, never blanket","Drop icons when converting an item to checkbox/radiobutton"],"tags":["dropdown-menu","menu","icon","php","config-conflict"],"backgroundTag":"invalid-config-combination","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}