Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SaveSplitButton.php
Go to the documentation of this file.
1 <?php
7 
10 
18 {
22  private $targetName;
23 
27  public function __construct(string $targetName)
28  {
29  $this->targetName = $targetName;
30  }
31 
35  public function getButtonData()
36  {
37  return [
38  'label' => __('Save &amp; Continue'),
39  'class' => 'save primary',
40  'data_attribute' => [
41  'mage-init' => [
42  'buttonAdapter' => [
43  'actions' => [
44  [
45  'targetName' => $this->targetName,
46  'actionName' => 'save',
47  'params' => [
48  // first param is redirect flag
49  false,
50  ]
51  ]
52  ]
53  ]
54  ]
55  ],
56  'class_name' => Container::SPLIT_BUTTON,
57  'options' => $this->getOptions(),
58  'sort_order' => 40,
59  ];
60  }
61 
65  private function getOptions(): array
66  {
67  $options = [
68  [
69  'label' => __('Save &amp; Close'),
70  'data_attribute' => [
71  'mage-init' => [
72  'buttonAdapter' => [
73  'actions' => [
74  [
75  'targetName' => $this->targetName,
76  'actionName' => 'save',
77  'params' => [
78  // first param is redirect flag
79  true,
80  ],
81  ],
82  ],
83  ],
84  ],
85  ],
86  'sort_order' => 10,
87  ],
88  [
89  'label' => __('Save &amp; New'),
90  'data_attribute' => [
91  'mage-init' => [
92  'buttonAdapter' => [
93  'actions' => [
94  [
95  'targetName' => $this->targetName,
96  'actionName' => 'save',
97  'params' => [
98  // first param is redirect flag, second is data that will be added to post
99  // request
100  true,
101  [
102  'redirect_to_new' => 1,
103  ],
104  ],
105  ],
106  ],
107  ],
108  ],
109  ],
110  'sort_order' => 20,
111  ],
112  ];
113  return $options;
114  }
115 }
__()
Definition: __.php:13