2 namespace TYPO3\CMS\Backend\Form\Element;
38 $table = $this->data[
'tableName'];
39 $field = $this->data[
'fieldName'];
40 $row = $this->data[
'databaseRow'];
41 $parameterArray = $this->data[
'parameterArray'];
42 $config = $parameterArray[
'fieldConf'][
'config'];
44 $selectItems = $parameterArray[
'fieldConf'][
'config'][
'items'];
49 $inlineStackProcessor->initializeByGivenStructure($this->data[
'inlineStructure']);
51 if ($this->data[
'isInlineChild'] && $this->data[
'inlineParentUid']) {
52 $inlineObjectName = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data[
'inlineFirstPid']);
53 $inlineFormName = $inlineStackProcessor->getCurrentStructureFormPrefix();
54 if ($this->data[
'inlineParentConfig'][
'foreign_table'] === $table
55 && $this->data[
'inlineParentConfig'][
'foreign_unique'] === $field
57 $uniqueIds = $this->data[
'inlineData'][
'unique'][$inlineObjectName .
'-' . $table][
'used'];
58 $parameterArray[
'fieldChangeFunc'][
'inlineUnique'] =
'inline.updateUnique(this,'
64 if ($this->data[
'inlineParentConfig'][
'foreign_table'] === $table
66 $this->data[
'inlineParentConfig'][
'foreign_field'] === $field
67 || $this->data[
'inlineParentConfig'][
'symmetric_field'] === $field
70 $uniqueIds[] = $this->data[
'inlineParentUid'];
77 $size = (int)$config[
'size'];
82 if (!empty($config[
'readOnly'])) {
87 $selectItemCounter = 0;
88 $selectItemGroupCount = 0;
89 $selectItemGroups = array();
90 $selectIcons = array();
94 if (!empty($parameterArray[
'itemFormElValue'])) {
95 $selectedValue = (string)$parameterArray[
'itemFormElValue'][0];
98 foreach ($selectItems as $item) {
99 if ($item[1] ===
'--div--') {
101 if ($selectItemCounter !== 0) {
102 $selectItemGroupCount++;
104 $selectItemGroups[$selectItemGroupCount][
'header'] = array(
109 $title = htmlspecialchars($item[
'0'], ENT_COMPAT,
'UTF-8',
false);
111 $selected = $selectedValue === (string)$item[1];
114 $selectedIcon = $icon;
117 $selectItemGroups[$selectItemGroupCount][
'items'][] = array(
121 'selected' => $selected,
122 'index' => $selectItemCounter
127 $selectIcons[] = array(
130 'index' => $selectItemCounter,
134 $selectItemCounter++;
140 if (!$selectedIcon && $selectItemGroups[0][
'items'][0][
'icon']) {
141 $selectedIcon = $selectItemGroups[0][
'items'][0][
'icon'];
145 foreach ($selectItemGroups as $selectItemGroup) {
147 if (empty($selectItemGroup[
'items'])) {
151 $optionGroup = is_array($selectItemGroup[
'header']);
152 $options .= ($optionGroup ?
'<optgroup label="' . htmlspecialchars($selectItemGroup[
'header'][
'title'], ENT_COMPAT,
'UTF-8',
false) .
'">' :
'');
154 if (is_array($selectItemGroup[
'items'])) {
155 foreach ($selectItemGroup[
'items'] as $item) {
156 $options .=
'<option value="' . htmlspecialchars($item[
'value']) .
'" data-icon="' .
157 htmlspecialchars($item[
'icon']) .
'"'
158 . ($item[
'selected'] ?
' selected="selected"' :
'') .
'>' . $item[
'title'] .
'</option>';
160 $hasIcons = !empty($item[
'icon']);
163 $options .= ($optionGroup ?
'</optgroup>' :
'');
167 $html = [
'<div class="form-control-wrap">'];
170 $html[] =
'<div class="input-group">';
171 $html[] =
'<span class="input-group-addon input-group-icon">';
172 $html[] = $selectedIcon;
177 .
' id="' . $selectId .
'"'
178 .
' name="' . htmlspecialchars($parameterArray[
'itemFormElName']) .
'"'
180 .
' class="form-control form-control-adapt"'
181 . ($size ?
' size="' . $size .
'"' :
'')
182 . ($disabled ?
' disabled="disabled"' :
'')
185 $html[] =
'</select>';
194 if (!empty($selectIcons) && !empty($config[
'showIconTable'])) {
195 $selectIconColumns = (int)$config[
'selicon_cols'];
197 if (!$selectIconColumns) {
198 $selectIconColumns = count($selectIcons);
201 $selectIconColumns = ($selectIconColumns > 12 ? 12 : $selectIconColumns);
202 $selectIconRows = ceil(count($selectIcons) / $selectIconColumns);
203 $selectIcons = array_pad($selectIcons, $selectIconRows * $selectIconColumns,
'');
205 $html[] =
'<div class="t3js-forms-select-single-icons table-icons table-fit table-fit-inline-block">';
206 $html[] =
'<table class="table table-condensed table-white table-center">';
210 foreach ($selectIcons as $i => $selectIcon) {
211 if ($i % $selectIconColumns === 0 && $i !== 0) {
218 if (is_array($selectIcon)) {
219 $html[] =
'<a href="#" title="' . $selectIcon[
'title'] .
'" data-select-index="' . $selectIcon[
'index'] .
'">';
220 $html[] = $selectIcon[
'icon'];
228 $html[] =
'</tbody>';
229 $html[] =
'</table>';
233 $html = implode(LF, $html);
237 $html = $this->renderWizards(
244 $parameterArray[
'itemFormElName'],
250 $resultArray[
'html'] = $html;
251 $resultArray[
'requireJsModules'][] = [
'TYPO3/CMS/Backend/FormEngine/Element/SelectSingleElement' => implode(LF, [
252 'function(SelectSingleElement) {',
253 'SelectSingleElement.initialize(',
256 'onChange: function() {',
257 implode(
'', $parameterArray[
'fieldChangeFunc']),
259 'onFocus: function() {',
260 $parameterArray[
'onFocus'],