Skip to content

Commit 047527d

Browse files
committed
Allow form buttons to be defined via XML layout
1 parent c999123 commit 047527d

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Component/Form/FormViewModel.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ public function getIndexUrl(): string
7474
*/
7575
public function getButtons(): array
7676
{
77+
$buttonDefinitions = $this->getBlock()->getButtons();
78+
if (!empty($buttonDefinitions)) {
79+
$buttons = [];
80+
foreach ($buttonDefinitions as $buttonDefinition) {
81+
$buttons[] = $this->buttonFactory->create(
82+
method: (string)$buttonDefinition['method'],
83+
label: (string)$buttonDefinition['label'],
84+
cssClass: isset($buttonDefinition['cssClass']) ? (string)$buttonDefinition['cssClass'] : '',
85+
url: isset($buttonDefinition['url']) ? (string)$buttonDefinition['url'] : '',
86+
primary: $buttonDefinition['primary'] ?? false,
87+
);
88+
}
89+
90+
return $buttons;
91+
}
92+
7793
$item = $this->getValue();
7894
if ($item instanceof DataObject && $item->getId() > 0) {
7995
return [

0 commit comments

Comments
 (0)