Important: #107681 - Disabled state for ShortcutButton and DropDownButton
See forge#107681
Description
The
Shortcut and
Drop classes in the TYPO3
backend button bar system have been enhanced with new methods to support
disabled state functionality. This brings them in line with other button
types that already support the disabled state.
Two new methods have been added to both classes:
is- Checks if the button is disabledDisabled (): bool set- Sets the disabled state of the buttonDisabled (bool $disabled)
When a button is disabled, it is rendered with appropriate HTML attributes
and CSS classes to indicate its non-interactive state. For
Shortcut,
the disabled state is applied to both the simple button rendering and the
dropdown rendering modes.
Impact
Extension developers can now programmatically disable shortcut and dropdown buttons in the TYPO3 backend, preventing user interaction when needed. This is particularly useful for:
- Preventing operations during form initialization
- Disabling buttons during async operations
- Conditional button availability based on application state
- Improving user experience on slow network connections
The disabled state is properly propagated through the rendering process:
- For shortcut buttons rendered as
Generic, the disabled attribute is added to the button elementButton - For shortcut buttons rendered as
Drop, the disabled state is passed to the dropdown buttonDown Button
Migration
No migration is required. This change is fully backward compatible as it only adds new optional functionality. Existing code will continue to work without modifications.
Example usage for disabling a shortcut button:
$shortcutButton = $buttonBar->makeShortcutButton()
->setRouteIdentifier('my_module')
->setDisplayName('My Module')
->setArguments(['id' => $pageId])
->setDisabled(true);
$buttonBar->addButton($shortcutButton);
Example usage for disabling a dropdown button:
$dropdownButton = GeneralUtility::makeInstance(DropDownButton::class)
->setLabel('Actions')
->setIcon($iconFactory->getIcon('actions-menu'))
->setDisabled(true);
$dropdownButton->addItem($item1);
$dropdownButton->addItem($item2);
$buttonBar->addButton($dropdownButton);
Example usage for checking disabled state:
if ($shortcutButton->isDisabled()) {
// Handle disabled state
}