TYPO3  7.6
RadioGroupJsonElement.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Form\Domain\Model\Json;
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 $xtype = 'typo3-form-wizard-elements-predefined-radiogroup';
28 
34  public $configuration = array(
35  'attributes' => array(),
36  'legend' => array(
37  'value' => ''
38  ),
39  'options' => array(),
40  'various' => array(
41  'name' => ''
42  ),
43  'validation' => array()
44  );
45 
51  protected $allowedAttributes = array(
52  'class',
53  'dir',
54  'id',
55  'lang',
56  'style'
57  );
58 
66  public function setParameters(array $parameters)
67  {
68  parent::setParameters($parameters);
69  $this->setOptions($parameters);
70  $this->setVarious($parameters);
71  }
72 
79  protected function setOptions(array $parameters)
80  {
81  if (is_array($parameters)) {
82  $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
83  foreach ($keys as $key) {
84  $class = $parameters[$key];
85  if ((int)$key && strpos($key, '.') === false) {
86  if (isset($parameters[$key . '.']) && $class === 'RADIO') {
87  $childElementArguments = $parameters[$key . '.'];
88  if (isset($childElementArguments['checked'])) {
89  $childElementArguments['attributes']['selected'] = 'selected';
90  unset($childElementArguments['checked']);
91  }
92  if (isset($childElementArguments['label.'])) {
93  $childElementArguments['data'] = $childElementArguments['label.']['value'];
94  unset($childElementArguments['label.']);
95  }
96  $this->configuration['options'][] = $childElementArguments;
97  }
98  }
99  }
100  }
101  }
102 
109  protected function setVarious(array $parameters)
110  {
111  if (isset($parameters['name'])) {
112  $this->configuration['various']['name'] = $parameters['name'];
113  }
114  }
115 }