FullyRenderedButton implements ButtonInterface

This button type is an intermediate solution for buttons that are rendered by methods from TYPO3 itself, like the CSH buttons or Bookmark buttons.

There should be no need to use them, so do yourself a favour and don't.

Example:

public function __construct(
    protected readonly ComponentFactory $componentFactory,
) }

public function myAction(): ResponseInterface
{
    $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
    $myButton = $this->componentFactory->createFullyRenderedButton()
         ->setHtmlSource('<span class="i-should-not-be-using-this>Foo</span>');
    $buttonBar->addButton($myButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
}

Table of Contents

Interfaces

ButtonInterface
Interface for buttons in the document header.

Properties

$htmlSource  : string
The full HTML source of the rendered button.

Methods

__toString()  : string
getHtmlSource()  : string
getType()  : string
Returns the fully qualified class name as the component type identifier.
isValid()  : bool
Validates whether the component is properly configured and can be rendered.
render()  : string
Renders the component as an HTML string.
setHtmlSource()  : static

Properties

$htmlSource

The full HTML source of the rendered button.

protected string $htmlSource = ''

This source will be passed through to the frontend as is, so keep htmlspecialchars() in mind.

Methods

__toString()

public __toString() : string
Return values
string

getHtmlSource()

public getHtmlSource() : string
Return values
string

getType()

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')

isValid()

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

setHtmlSource()

public setHtmlSource(string $htmlSource) : static
Parameters
$htmlSource : string
Return values
static

        
On this page

Search results