2 declare(strict_types = 1);
21 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
34 'int' =>
'renderIntegerField',
35 'int+' =>
'renderPositiveIntegerField',
36 'integer' =>
'renderIntegerField',
37 'color' =>
'renderColorPicker',
38 'wrap' =>
'renderWrapField',
39 'offset' =>
'renderOffsetField',
40 'options' =>
'renderOptionSelect',
41 'boolean' =>
'renderCheckbox',
42 'user' =>
'renderUserFunction',
43 'small' =>
'renderSmallTextField',
44 'string' =>
'renderTextField',
45 'input' =>
'renderTextField',
46 'default' =>
'renderTextField'
59 parent::initializeArguments();
60 $this->registerArgument(
'name',
'string',
'Name of input tag');
61 $this->registerArgument(
'value',
'mixed',
'Value of input tag');
62 $this->registerArgument(
'configuration',
'array',
'',
true);
63 $this->registerUniversalTagAttributes();
71 $this->setTagBuilder(
new TagBuilder($this->tagName));
80 public function render():
string
83 $configuration = $this->arguments[
'configuration'];
84 if (isset($this->viewHelperMapping[$configuration[
'type']]) && method_exists($this, $this->viewHelperMapping[$configuration[
'type']])) {
85 $input = $this->{$this->viewHelperMapping[$configuration[
'type']]}($configuration);
87 $input = $this->{$this->viewHelperMapping[
'default']}($configuration);
101 $elementName = $this->
getName($configuration);
104 $this->tag->setTagName(
'input');
105 $this->tag->addAttribute(
'type',
'text');
107 $this->tag->addAttribute(
'name', $elementName);
108 $this->tag->addAttribute(
'data-formengine-input-name', $elementName);
109 $this->tag->addAttribute(
'class',
'form-control');
110 if ($configuration[
'value'] !==
null) {
111 $this->tag->addAttribute(
'value', $configuration[
'value']);
115 <div class="form-wizards-element">
116 <input class="form-control t3js-color-input formengine-colorpickerelement t3js-color-picker" type="text"
117 name="' . htmlspecialchars($elementName) .
'" value="' . $this->tag->getAttribute(
'value') .
'"/>
118 <script type="text/javascript">
119 require([\'TYPO3/CMS/Backend/ColorPicker\'], function(ColorPicker){ColorPicker.initialize()});
134 $this->tag->setTagName(
'input');
135 $this->tag->addAttribute(
'type',
'text');
137 $this->tag->addAttribute(
'name', $this->
getName($configuration));
138 $this->tag->addAttribute(
'class',
'form-control t3js-emconf-offset');
139 if ($configuration[
'value'] !==
null) {
140 $this->tag->addAttribute(
'value', $configuration[
'value']);
142 return $this->tag->render();
153 $this->tag->setTagName(
'input');
154 $this->tag->addAttribute(
'type',
'text');
156 $this->tag->addAttribute(
'name', $this->
getName($configuration));
157 $this->tag->addAttribute(
'class',
'form-control t3js-emconf-wrap');
158 if ($configuration[
'value'] !==
null) {
159 $this->tag->addAttribute(
'value', $configuration[
'value']);
161 return $this->tag->render();
172 $this->tag->setTagName(
'select');
174 $this->tag->addAttribute(
'name', $this->
getName($configuration));
175 $this->tag->addAttribute(
'class',
'form-control');
176 $optionValueArray = $configuration[
'generic'];
179 foreach ($optionValueArray as $label => $value) {
180 $output .=
'<option value="' . htmlspecialchars($value) .
'"';
181 if ($configuration[
'value'] == $value) {
184 $output .=
'>' . htmlspecialchars($languageService->sL($label)) .
'</option>';
187 return $this->tag->render();
198 $this->tag->setTagName(
'input');
199 $this->tag->addAttribute(
'type',
'number');
201 $this->tag->addAttribute(
'name', $this->
getName($configuration));
202 $this->tag->addAttribute(
'class',
'form-control');
203 $this->tag->addAttribute(
'min',
'0');
204 if ($configuration[
'value'] !==
null) {
205 $this->tag->addAttribute(
'value', $configuration[
'value']);
207 return $this->tag->render();
218 $this->tag->setTagName(
'input');
219 $this->tag->addAttribute(
'type',
'number');
221 $this->tag->addAttribute(
'name', $this->
getName($configuration));
222 $this->tag->addAttribute(
'class',
'form-control');
223 if ($configuration[
'value'] !==
null) {
224 $this->tag->addAttribute(
'value', $configuration[
'value']);
226 return $this->tag->render();
237 $this->tag->setTagName(
'input');
238 $this->tag->addAttribute(
'type',
'text');
240 $this->tag->addAttribute(
'name', $this->
getName($configuration));
241 $this->tag->addAttribute(
'class',
'form-control');
242 if ($configuration[
'value'] !==
null) {
243 $this->tag->addAttribute(
'value', $configuration[
'value']);
245 return $this->tag->render();
267 $this->tag->addAttribute(
'type',
'checkbox');
268 $this->tag->addAttribute(
'name', $this->
getName($configuration));
269 $this->tag->addAttribute(
'value', 1);
271 if ($configuration[
'value'] == 1) {
272 $this->tag->addAttribute(
'checked',
'checked');
275 return '<div class="checkbox">' . $hiddenField .
'<label>' . $this->tag->render() .
'</label></div>';
286 $userFunction = $configuration[
'generic'];
287 $userFunctionParams = [
288 'fieldName' => $this->
getName($configuration),
289 'fieldValue' => $configuration[
'value'],
290 'propertyName' => $configuration[
'name']
292 return (
string)GeneralUtility::callUserFunction($userFunction, $userFunctionParams, $this);
301 protected function getName(array $configuration):
string
303 return $configuration[
'name'];
314 $hiddenFieldNames = [];
317 $variableKey =
'renderedHiddenFields-' . $configuration[
'extensionKey'];
318 if ($this->viewHelperVariableContainer->exists(FormViewHelper::class, $variableKey)) {
319 $hiddenFieldNames = $this->viewHelperVariableContainer->get(FormViewHelper::class, $variableKey);
321 $fieldName = $this->
getName($configuration);
322 if (substr($fieldName, -2) ===
'[]') {
323 $fieldName = substr($fieldName, 0, -2);
325 if (!in_array($fieldName, $hiddenFieldNames)) {
326 $hiddenFieldNames[] = $fieldName;
327 $this->viewHelperVariableContainer->addOrUpdate(FormViewHelper::class, $variableKey, $hiddenFieldNames);
328 return '<input type="hidden" name="' . htmlspecialchars($fieldName) .
'" value="0" />';
348 $this->tag->addAttribute(
350 'em-' . $configuration[
'extensionKey'] .
'-' . $this->
getName($configuration)