TYPO3 CMS  TYPO3_7-6
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  public function render()
28  {
29  $disabled = '';
30  if ($this->data['parameterArray']['fieldConf']['config']['readOnly']) {
31  $disabled = ' disabled';
32  }
33 
34  $html = [];
35  foreach ($this->data['parameterArray']['fieldConf']['config']['items'] as $itemNumber => $itemLabelAndValue) {
36  $label = $itemLabelAndValue[0];
37  $value = $itemLabelAndValue[1];
38  $radioId = htmlspecialchars($this->data['parameterArray']['itemFormElID'] . '_' . $itemNumber);
39  $radioChecked = (string)$value === (string)$this->data['parameterArray']['itemFormElValue'] ? ' checked="checked"' : '';
40  $html[] = '<div class="radio' . $disabled . '">';
41  $html[] = '<label for="' . $radioId . '">';
42  $html[] = '<input type="radio"'
43  . ' name="' . htmlspecialchars($this->data['parameterArray']['itemFormElName']) . '"'
44  . ' id="' . $radioId . '"'
45  . ' value="' . htmlspecialchars($value) . '"'
46  . $radioChecked
47  . $this->data['parameterArray']['onFocus']
48  . $disabled
49  . ' onclick="' . htmlspecialchars(implode('', $this->data['parameterArray']['fieldChangeFunc'])) . '"'
50  . '/>'
51  . htmlspecialchars($label);
52  $html[] = '</label>';
53  $html[] = '</div>';
54  }
55 
56  $resultArray = $this->initializeResultArray();
57  $resultArray['html'] = implode(LF, $html);
58  return $resultArray;
59  }
60 }