DropDownButton implements ButtonInterface
This button type is a container for dropdown items.
It will render a dropdown containing all items attached to it. There are different kinds available, each item needs to implement the DropDownItemInterface. When this type contains elements of type DropDownRadio it will use the icon of the first active item of this type.
Example:
public function __construct(
protected readonly ComponentFactory $componentFactory,
) }
public function myAction(): ResponseInterface
{
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
$dropDownButton = $this->componentFactory->createDropDownButton()
->setLabel('Dropdown')
->setTitle('Save')
->setIcon($this->iconFactory->getIcon('actions-heart'))
->getShowLabelText(true)
->addItem(
GeneralUtility::makeInstance(DropDownItem::class)
->setLabel('Item')
->setHref('#')
);
$buttonBar->addButton($dropDownButton, ButtonBar::BUTTON_POSITION_RIGHT, 2);
}
Table of Contents
Interfaces
- ButtonInterface
- Interface for buttons in the document header.
Properties
- $disabled : bool
- $icon : Icon|null
- $items : array<string|int, mixed>
- $label : string
- $showLabelText : bool
- $size : ButtonSize
- $title : string|null
Methods
- __toString() : string
- addItem() : static
- getIcon() : Icon|null
- getItems() : array<string|int, DropDownItemInterface>
- getLabel() : string
- getShowLabelText() : bool
- getSize() : ButtonSize
- getTitle() : string
- getType() : string
- Returns the fully qualified class name as the component type identifier.
- isDisabled() : bool
- isValid() : bool
- Validates whether the component is properly configured and can be rendered.
- render() : string
- Renders the component as an HTML string.
- setDisabled() : static
- setIcon() : static
- setLabel() : static
- setShowLabelText() : static
- setSize() : DropDownButton
- setTitle() : static
Properties
$disabled
protected
bool
$disabled
= false
$icon
protected
Icon|null
$icon
= null
$items
protected
array<string|int, mixed>
$items
= []
$label
protected
string
$label
= ''
$showLabelText
protected
bool
$showLabelText
= false
$size
protected
ButtonSize
$size
= \TYPO3\CMS\Backend\Template\Components\Buttons\ButtonSize::SMALL
$title
protected
string|null
$title
= null
Methods
__toString()
public
__toString() : string
Return values
stringaddItem()
public
addItem(DropDownItemInterface $item) : static
Parameters
- $item : DropDownItemInterface
Return values
staticgetIcon()
public
getIcon() : Icon|null
Return values
Icon|nullgetItems()
public
getItems() : array<string|int, DropDownItemInterface>
Return values
array<string|int, DropDownItemInterface>getLabel()
public
getLabel() : string
Return values
stringgetShowLabelText()
public
getShowLabelText() : bool
Return values
boolgetSize()
public
getSize() : ButtonSize
Return values
ButtonSizegetTitle()
public
getTitle() : string
Return values
stringgetType()
Returns the fully qualified class name as the component type identifier.
public
getType() : string
This is used to identify the specific component type in validation and rendering.
Return values
string —The fully qualified class name (e.g., 'TYPO3\CMS\Backend\Template\Components\Buttons\LinkButton')
isDisabled()
public
isDisabled() : bool
Return values
boolisValid()
Validates whether the component is properly configured and can be rendered.
public
isValid() : bool
Each implementing class defines its own validation rules (e.g., required fields).
Return values
bool —True if the component is valid and can be rendered, false otherwise
render()
Renders the component as an HTML string.
public
render() : string
This method should only be called after validating the component with isValid(). The returned HTML is ready to be output to the browser.
Return values
string —The rendered HTML markup
setDisabled()
public
setDisabled(bool $disabled) : static
Parameters
- $disabled : bool
Return values
staticsetIcon()
public
setIcon(Icon|null $icon) : static
Parameters
- $icon : Icon|null
Return values
staticsetLabel()
public
setLabel(string $label) : static
Parameters
- $label : string
Return values
staticsetShowLabelText()
public
setShowLabelText(bool $showLabelText) : static
Parameters
- $showLabelText : bool
Return values
staticsetSize()
public
setSize(ButtonSize $size) : DropDownButton
Parameters
- $size : ButtonSize
Return values
DropDownButtonsetTitle()
public
setTitle(string|null $title) : static
Parameters
- $title : string|null