[TASK] EXT:form - Add HTML4 / HTML5 attributes for SELECT to wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Model / Json / SelectJsonElement.php
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
17 /**
18 * JSON select
19 */
20 class SelectJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement {
21
22 /**
23 * The ExtJS xtype of the element
24 *
25 * @var string
26 */
27 public $xtype = 'typo3-form-wizard-elements-basic-select';
28
29 /**
30 * The configuration array for the xtype
31 *
32 * @var array
33 */
34 public $configuration = array(
35 'attributes' => array(),
36 'filters' => array(),
37 'label' => array(
38 'value' => ''
39 ),
40 'layout' => 'front',
41 'options' => array(),
42 'validation' => array()
43 );
44
45 /**
46 * Allowed attributes for this object
47 *
48 * @var array
49 */
50 protected $allowedAttributes = array(
51 'accesskey',
52 'class',
53 'contenteditable',
54 'contextmenu',
55 'dir',
56 'draggable',
57 'dropzone',
58 'hidden',
59 'id',
60 'lang',
61 'spellcheck',
62 'style',
63 'tabindex',
64 'title',
65 'translate',
66 /* element specific attributes */
67 'autofocus',
68 'disabled',
69 'multiple',
70 'name',
71 'required',
72 'size'
73 );
74
75 protected $childElementsAllowed = FALSE;
76
77 /**
78 * Set all the parameters for this object
79 *
80 * @param array $parameters Configuration array
81 * @return void
82 * @see \TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement::setParameters()
83 */
84 public function setParameters(array $parameters) {
85 parent::setParameters($parameters);
86 $this->setOptions($parameters);
87 }
88
89 /**
90 * Set the options for this object
91 *
92 * @param array $parameters Configuration array
93 * @return void
94 */
95 protected function setOptions(array $parameters) {
96 if (is_array($parameters)) {
97 $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
98 foreach ($keys as $key) {
99 $class = $parameters[$key];
100 if ((int)$key && strpos($key, '.') === FALSE) {
101 if (isset($parameters[$key . '.']) && $class === 'OPTION') {
102 $childElementArguments = $parameters[$key . '.'];
103 if (isset($childElementArguments['selected'])) {
104 $childElementArguments['attributes']['selected'] = $childElementArguments['selected'];
105 unset($childElementArguments['selected']);
106 if (isset($childElementArguments['value'])) {
107 $childElementArguments['attributes']['value'] = $childElementArguments['value'];
108 unset($childElementArguments['value']);
109 }
110 $this->configuration['options'][] = $childElementArguments;
111 }
112 $this->configuration['options'][] = $childElementArguments;
113 }
114 }
115 }
116 }
117 }
118
119 }