and takes the HTML attributes * name and value as additional attributes to those defined in AbstractButton. * * Since we no longer want to have any in the TYPO3 core * you should use this button type to send forms * * 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'); * $buttonBar->addButton($saveButton, ButtonBar::BUTTON_POSITION_LEFT, 1); * } * ``` */ class InputButton extends AbstractButton { protected string $name = ''; protected string $value = ''; protected string $form = ''; public function getName(): string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getValue(): string { return $this->value; } public function setValue(string $value): static { $this->value = $value; return $this; } public function getForm(): string { return $this->form; } public function setForm(string $form): static { $this->form = $form; return $this; } public function isValid(): bool { return trim($this->getName()) !== '' && trim($this->getValue()) !== '' && trim($this->getTitle()) !== '' && $this->getType() === static::class && $this->getIcon() !== null; } public function render(): string { $attributes = [ 'name' => $this->getName(), 'class' => 'btn btn-sm btn-default ' . $this->getClasses(), 'value' => $this->getValue(), 'title' => $this->getTitle(), 'form' => trim($this->getForm()), ]; if ($this->isDisabled()) { $attributes['disabled'] = 'disabled'; } $labelText = ''; if ($this->showLabelText) { $labelText = ' ' . $this->title; } foreach ($this->attributes as $attributeName => $attributeValue) { $attributes[$attributeName] = $attributeValue; } foreach ($this->dataAttributes as $attributeName => $attributeValue) { $attributes['data-' . $attributeName] = $attributeValue; } return sprintf( '', GeneralUtility::implodeAttributes($attributes, true), $this->getIcon()?->render() ?? '', htmlspecialchars($labelText) ); } public function __toString(): string { return $this->render(); } }