LinkButton

class \TYPO3\CMS\Backend\Template\Components\Buttons\LinkButton

Extends
AbstractButton

LinkButton

This button type renders a regular anchor tag with TYPO3s way to render a button control.

EXAMPLE USAGE TO ADD A BUTTON TO THE FIRST BUTTON GROUP IN THE LEFT BAR:

$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); $saveButton = $buttonBar->makeLinkButton() ->setHref('#') ->setDataAttributes([ 'foo' => 'bar' ]) ->setIcon($this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL)) ->setTitle('Save'); $buttonBar->addButton($saveButton, ButtonBar::BUTTON_POSITION_LEFT, 1);

Table of Contents

Properties

$classes  : string
HTML tag attribute for class
$dataAttributes  : array
HTML tag attributes for data-* Use key => value pairs
$disabled  : bool
Disabled state of the button
$href  : string
HREF attribute of the link
$icon  : Icon
Icon object
$onClick  : string
HTML tag attribute onClick Outdated, use sparingly
$showLabelText  : bool
Defines whether to show the title as a label within the button
$title  : string
HTML tag attribute for title

Methods

__toString()  : string
Magic method so Fluid can access a button via {button}
getClasses()  : string
Get classes
getDataAttributes()  : array
Get Data attributes
getHref()  : string
Get href
getIcon()  : Icon
Get icon
getOnClick()  : string
Get Onclick Attribute
getShowLabelText()  : bool
Show Label text
getTitle()  : string
Get Title
getType()  : string
Get type
hasOnClick()  : bool
Helper method to avoid using `getOnClick` in TYPO3 core.
isDisabled()  : bool
Check if button is disabled
isValid()  : bool
Validates the current button
render()  : string
Renders the markup for the button
setClasses()  : $this
Set classes
setDataAttributes()  : $this
Set Data attributes
setDisabled()  : AbstractButton
Set if button needs to be disabled
setHref()  : LinkButton
Set href
setIcon()  : $this
Set icon
setOnClick()  : $this
Set OnClick
setShowLabelText()  : $this
Show Label text
setTitle()  : $this
Set title attribute

Properties

$classes

HTML tag attribute for class

protected string $classes = ''

$dataAttributes

HTML tag attributes for data-* Use key => value pairs

protected array $dataAttributes = []

$disabled

Disabled state of the button

protected bool $disabled = false

$href

HREF attribute of the link

protected string $href = ''

$onClick

HTML tag attribute onClick Outdated, use sparingly

Deprecated

Use HTML data attrs for GlobalEventHandler or ActionDispatcher instead. Will be removed in TYPO3 v12.0

protected string $onClick = ''

$showLabelText

Defines whether to show the title as a label within the button

protected bool $showLabelText = false

$title

HTML tag attribute for title

protected string $title = ''

Methods

__toString()

Magic method so Fluid can access a button via {button}

public __toString() : string

Return values

string

getClasses()

Get classes

public getClasses() : string

Return values

string

getDataAttributes()

Get Data attributes

public getDataAttributes() : array

Return values

array

getHref()

Get href

public getHref() : string

Return values

string

getOnClick()

Get Onclick Attribute

public getOnClick() : string

Deprecated

Use HTML data attrs for GlobalEventHandler or ActionDispatcher instead. Will be removed in TYPO3 v12.0

Return values

string

getShowLabelText()

Show Label text

public getShowLabelText() : bool

Return values

bool

getTitle()

Get Title

public getTitle() : string

Return values

string

getType()

Get type

public getType() : string

Return values

string

hasOnClick()

Helper method to avoid using `getOnClick` in TYPO3 core.

public hasOnClick() : bool

Deprecated

Introduced with TYPO3 v11.5, will be removed with TYPO3 v12.0

Return values

bool

isDisabled()

Check if button is disabled

public isDisabled() : bool

Return values

bool

isValid()

Validates the current button

public isValid() : bool

Return values

bool

render()

Renders the markup for the button

public render() : string

Return values

string

setClasses()

Set classes

public setClasses(string $classes) : $this

Parameters

$classes : string

HTML class attribute to set

Return values

$this

setDataAttributes()

Set Data attributes

public setDataAttributes(array $dataAttributes) : $this

Parameters

$dataAttributes : array

HTML data attributes to set

Return values

$this

setIcon()

Set icon

public setIcon(Icon $icon) : $this

Parameters

$icon : Icon

Icon object for the button

Return values

$this

setOnClick()

Set OnClick

public setOnClick(string $onClick) : $this

Deprecated

Use HTML data attrs for GlobalEventHandler or ActionDispatcher instead. Will be removed in TYPO3 v12.0

Parameters

$onClick : string

HTML onClick attribute to set

Return values

$this

setShowLabelText()

Show Label text

public setShowLabelText(bool $showLabelText) : $this

Parameters

$showLabelText : bool

Return values

$this

setTitle()

Set title attribute

public setTitle(string $title) : $this

Parameters

$title : string

HTML title attribute to set

Return values

$this
On this page