‪TYPO3CMS  10.4
RadioElement.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 {
28  protected ‪$defaultFieldInformation = [
29  'tcaDescription' => [
30  'renderType' => 'tcaDescription',
31  ],
32  ];
33 
39  protected ‪$defaultFieldWizard = [
40  'localizationStateSelector' => [
41  'renderType' => 'localizationStateSelector',
42  ],
43  'otherLanguageContent' => [
44  'renderType' => 'otherLanguageContent',
45  'after' => [
46  'localizationStateSelector'
47  ],
48  ],
49  'defaultLanguageDifferences' => [
50  'renderType' => 'defaultLanguageDifferences',
51  'after' => [
52  'otherLanguageContent',
53  ],
54  ],
55  ];
56 
62  public function ‪render()
63  {
64  $resultArray = $this->‪initializeResultArray();
65 
66  $disabled = '';
67  if ($this->data['parameterArray']['fieldConf']['config']['readOnly']) {
68  $disabled = ' disabled';
69  }
70 
71  $fieldInformationResult = $this->‪renderFieldInformation();
72  $fieldInformationHtml = $fieldInformationResult['html'];
73  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
74 
75  $fieldWizardResult = $this->‪renderFieldWizard();
76  $fieldWizardHtml = $fieldWizardResult['html'];
77  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false);
78 
79  $html = [];
80  $html[] = '<div class="formengine-field-item t3js-formengine-field-item">';
81  $html[] = $fieldInformationHtml;
82  $html[] = '<div class="form-wizards-wrap">';
83  $html[] = '<div class="form-wizards-element">';
84  foreach ($this->data['parameterArray']['fieldConf']['config']['items'] as $itemNumber => $itemLabelAndValue) {
85  $label = $itemLabelAndValue[0];
86  $value = $itemLabelAndValue[1];
87  $radioId = htmlspecialchars($this->data['parameterArray']['itemFormElID'] . '_' . $itemNumber);
88  $radioChecked = (string)$value === (string)$this->data['parameterArray']['itemFormElValue'] ? ' checked="checked"' : '';
89 
90  $html[] = '<div class="radio' . $disabled . '">';
91  $html[] = '<label for="' . $radioId . '">';
92  $html[] = '<input type="radio"';
93  $html[] = ' name="' . htmlspecialchars($this->data['parameterArray']['itemFormElName']) . '"';
94  $html[] = ' id="' . $radioId . '"';
95  $html[] = ' value="' . htmlspecialchars($value) . '"';
96  $html[] = $radioChecked;
97  $html[] = $disabled;
98  $html[] = ' onclick="' . htmlspecialchars(implode('', $this->data['parameterArray']['fieldChangeFunc'])) . '"';
99  $html[] = '/>';
100  $html[] = htmlspecialchars($this->‪appendValueToLabelInDebugMode($label, $value));
101  $html[] = '</label>';
102  $html[] = '</div>';
103  }
104  $html[] = '</div>';
105  if (!$disabled && !empty($fieldWizardHtml)) {
106  $html[] = '<div class="form-wizards-items-bottom">';
107  $html[] = $fieldWizardHtml;
108  $html[] = '</div>';
109  }
110  $html[] = '</div>';
111  $html[] = '</div>';
112 
113  $resultArray['html'] = implode(LF, $html);
114  return $resultArray;
115  }
116 }
‪TYPO3\CMS\Backend\Form\Element\AbstractFormElement\renderFieldInformation
‪array renderFieldInformation()
Definition: AbstractFormElement.php:72
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:116
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:90
‪TYPO3\CMS\Backend\Form\Element\RadioElement\$defaultFieldInformation
‪array $defaultFieldInformation
Definition: RadioElement.php:27
‪TYPO3\CMS\Backend\Form\Element\AbstractFormElement
Definition: AbstractFormElement.php:32
‪TYPO3\CMS\Backend\Form\Element
Definition: AbstractFormElement.php:16
‪TYPO3\CMS\Backend\Form\Element\RadioElement\$defaultFieldWizard
‪array $defaultFieldWizard
Definition: RadioElement.php:37
‪TYPO3\CMS\Backend\Form\Element\RadioElement\render
‪array render()
Definition: RadioElement.php:60
‪TYPO3\CMS\Backend\Form\Element\AbstractFormElement\appendValueToLabelInDebugMode
‪string appendValueToLabelInDebugMode($label, $value)
Definition: AbstractFormElement.php:378
‪TYPO3\CMS\Backend\Form\Element\RadioElement
Definition: RadioElement.php:22
‪TYPO3\CMS\Backend\Form\Element\AbstractFormElement\renderFieldWizard
‪array renderFieldWizard()
Definition: AbstractFormElement.php:104