SplitButton extends AbstractButton
This button type renders a bootstrap split button.
It takes multiple button objects as parameters.
The button objects must contain at least one primary button that is displayed as the main icon, and all other items will be revealed within a dropdown.
If a button is of Type "LinkButton" it will not utilize a
HTML <button> tag, but instead use <a>.
Example:
public function __construct(
protected readonly ComponentFactory $componentFactory,
) }
public function myAction(): ResponseInterface
{
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
$saveButton = $this->componentFactory->createInputButton()
->setName('save')
->setValue('1')
->setIcon($this->iconFactory->getIcon('actions-document-save', IconSize::SMALL))
->setTitle('Save');
$saveAndCloseButton = $this->componentFactory->createInputButton()
->setName('save_and_close')
->setValue('1')
->setTitle('Save and close')
->setIcon($this->iconFactory->getIcon('actions-document-save-close', IconSize::SMALL));
$saveAndShowPageButton = $this->componentFactory->createInputButton()
->setName('save_and_show')
->setValue('1')
->setTitle('Save and show')
->setIcon($this->iconFactory->getIcon('actions-document-save-view', IconSize::SMALL));
$moduleLink = $this->componentFactory->createLinkButton()
->setHref((string)$this->uriBuilder->buildUriFromRoute('file_edit', $parameter))
->setDataAttributes(['customAttribute' => 'customValue'])
->setShowLabelText(true)
->setTitle('Edit file')
->setIcon($this->iconFactory->getIcon('file-edit', IconSize::SMALL));
$splitButtonElement = $this->componentFactory->createSplitButton()
->addItem($saveButton, true)
->addItem($saveAndCloseButton)
->addItem($moduleLink)
->addItem($saveAndShowPageButton);
}
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- Attributes for the button
- $classes : string
- CSS classes to apply to the rendered element
- $containsPrimaryAction : bool
- Internal var that determines whether the split button has received any primary actions yet
- $dataAttributes : array<string, string>
- HTML data-* attributes for the control
- $disabled : bool
- Whether the button is in disabled state
- $icon : Icon|null
- Optional icon to display on the button
- $options : array<string|int, AbstractButton>
- Array of option buttons for the dropdown
- $primary : AbstractButton|null
- Primary action button
- $showLabelText : bool
- Whether to show the button's label text (from title property).
- $title : string
- Title/label text for the control
Methods
- __toString() : string
- Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
- addItem() : static
- Adds an instance of any button to the split button
- getAttributes() : array<string, string>
- getClasses() : string
- getDataAttributes() : array<string|int, mixed>
- getIcon() : Icon|null
- getItems() : SplitButtonItems
- Returns the split button items as a typed DTO.
- getShowLabelText() : bool
- getTitle() : string
- getType() : string
- Returns the fully qualified class name as the component type identifier.
- isDisabled() : bool
- isValid() : bool
- Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
- render() : string
- Renders the HTML markup of the button
- setAttributes() : static
- setClasses() : static
- setDataAttributes() : static
- setDisabled() : static
- setIcon() : static
- setShowLabelText() : static
- setTitle() : static
Properties
$attributes
Attributes for the button
protected
array<string|int, mixed>
$attributes
= []
$classes
CSS classes to apply to the rendered element
protected
string
$classes
= ''
$containsPrimaryAction
Internal var that determines whether the split button has received any primary actions yet
protected
bool
$containsPrimaryAction
= false
$dataAttributes
HTML data-* attributes for the control
protected
array<string, string>
$dataAttributes
= []
Key-value pairs (e.g., ['action' => 'save'])
$disabled
Whether the button is in disabled state
protected
bool
$disabled
= false
$icon
Optional icon to display on the button
protected
Icon|null
$icon
= null
$options
Array of option buttons for the dropdown
protected
array<string|int, AbstractButton>
$options
= []
$primary
Primary action button
protected
AbstractButton|null
$primary
= null
$showLabelText
Whether to show the button's label text (from title property).
protected
bool
$showLabelText
= false
If false, only the icon is shown (label is used for title attribute).
$title
Title/label text for the control
protected
string
$title
= ''
Methods
__toString()
Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
public
__toString() : string
Return values
stringaddItem()
Adds an instance of any button to the split button
public
addItem(AbstractButton $item[, bool $primaryAction = false ]) : static
Parameters
- $item : AbstractButton
-
ButtonObject to add
- $primaryAction : bool = false
-
Is the button the primary action?
Tags
Return values
staticgetAttributes()
public
getAttributes() : array<string, string>
Return values
array<string, string>getClasses()
public
getClasses() : string
Return values
stringgetDataAttributes()
public
getDataAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getIcon()
public
getIcon() : Icon|null
Return values
Icon|nullgetItems()
Returns the split button items as a typed DTO.
public
getItems() : SplitButtonItems
If no primary action was explicitly set, the first option button becomes the primary action.
Return values
SplitButtonItems —The typed container with primary and option buttons
getShowLabelText()
public
getShowLabelText() : bool
Return values
boolgetTitle()
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()
Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
public
isValid() : bool
Return values
bool —True if the component is valid and can be rendered, false otherwise
render()
Renders the HTML markup of the button
public
render() : string
Return values
stringsetAttributes()
public
setAttributes(array<string, string> $attributes) : static
Parameters
- $attributes : array<string, string>
Return values
staticsetClasses()
public
setClasses(string $classes) : static
Parameters
- $classes : string
Return values
staticsetDataAttributes()
public
setDataAttributes(array<string|int, mixed> $dataAttributes) : static
Parameters
- $dataAttributes : array<string|int, mixed>
Return values
staticsetDisabled()
public
setDisabled(bool $disabled) : static
Parameters
- $disabled : bool
Return values
staticsetIcon()
public
setIcon(Icon|null $icon) : static
Parameters
- $icon : Icon|null
Return values
staticsetShowLabelText()
public
setShowLabelText(bool $showLabelText) : static
Parameters
- $showLabelText : bool
Return values
staticsetTitle()
public
setTitle(string $title) : static
Parameters
- $title : string