2 namespace TYPO3\CMS\Backend\Template\Components\Buttons;
80 throw new \InvalidArgumentException(
81 'Only valid items may be assigned to a split Button. "' .
83 '" did not pass validation',
87 if ($primaryAction && $this->containsPrimaryAction) {
88 throw new \InvalidArgumentException(
'A splitButton may only contain one primary action', 1441706340);
91 $this->containsPrimaryAction =
true;
92 $this->items[
'primary'] = clone $item;
94 $this->items[
'options'][] = clone $item;
106 if (!isset($this->items[
'primary']) && isset($this->items[
'options'])) {
107 $primaryAction = array_shift($this->items[
'options']);
108 $this->items[
'primary'] = $primaryAction;
122 if (isset($subject[
'primary'])
124 && isset($subject[
'options'])
141 'class' =>
'btn btn-sm btn-default ' . htmlspecialchars(
$items[
'primary']->
getClasses()),
142 'name' =>
$items[
'primary']->getName(),
143 'value' =>
$items[
'primary']->getValue()
146 $attributes[
'onclick'] =
$items[
'primary']->getOnClick();
148 if (!empty(
$items[
'primary']->getForm())) {
149 $attributes[
'form'] =
$items[
'primary']->getForm();
151 $attributesString =
'';
152 foreach ($attributes as $key => $value) {
153 $attributesString .=
' ' . htmlspecialchars($key) .
'="' . htmlspecialchars($value) .
'"';
156 <div class="btn-group t3js-splitbutton">
157 <button' . $attributesString .
'>
158 ' .
$items[
'primary']->getIcon()->render() .
'
161 <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
162 <span class="caret"></span>
163 <span class="sr-only">Toggle Dropdown</span>
165 <ul class="dropdown-menu">';
168 foreach (
$items[
'options'] as $option) {
169 $optionAttributes = [
171 'data-name' => $option->getName(),
172 'data-value' => $option->getValue(),
173 'data-form' => $option->getForm()
175 if (!empty($option->getClasses())) {
176 $optionAttributes[
'class'] = htmlspecialchars($option->getClasses());
178 if (!empty($option->getOnClick())) {
179 $optionAttributes[
'onclick'] = $option->getOnClick();
181 $optionAttributesString =
'';
182 foreach ($optionAttributes as $key => $value) {
183 $optionAttributesString .=
' ' . htmlspecialchars($key) .
'="' . htmlspecialchars($value) .
'"';
187 <a' . $optionAttributesString .
'>' . $option->getIcon()->render() .
' '
188 . htmlspecialchars($option->getTitle()) .
'</a>