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