2 namespace TYPO3\CMS\Form\Domain\Builder;
34 $elementBuilder = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(ElementBuilder::class);
36 $elementBuilder->setElement($element);
37 $elementBuilder->setUserConfiguredElementTyposcript($userDefinedTypoScript);
38 return $elementBuilder;
118 if (!isset($this->userConfiguredElementTyposcript[
'partialPath'])) {
119 $partialPath = $this->typoScriptRepository->getDefaultFluidTemplate($this->element->getElementType());
121 $partialPath = $this->userConfiguredElementTyposcript[
'partialPath'];
122 unset($this->userConfiguredElementTyposcript[
'partialPath']);
124 $this->element->setPartialPath($partialPath);
135 if ($this->formBuilder->getControllerAction() ===
'show') {
136 if (!isset($this->userConfiguredElementTyposcript[
'visibleInShowAction'])) {
137 $visibility = (bool)$this->typoScriptRepository->getModelConfigurationByScope($this->element->getElementType(),
'visibleInShowAction');
139 $visibility = (bool)$this->userConfiguredElementTyposcript[
'visibleInShowAction'];
141 }
elseif ($this->formBuilder->getControllerAction() ===
'confirmation') {
142 if (!isset($this->userConfiguredElementTyposcript[
'visibleInConfirmationAction'])) {
143 $visibility = (bool)$this->typoScriptRepository->getModelConfigurationByScope($this->element->getElementType(),
'visibleInConfirmationAction');
145 $visibility = (bool)$this->userConfiguredElementTyposcript[
'visibleInConfirmationAction'];
147 }
elseif ($this->formBuilder->getControllerAction() ===
'process') {
148 if (!isset($this->userConfiguredElementTyposcript[
'visibleInMail'])) {
149 $visibility = (bool)$this->typoScriptRepository->getModelConfigurationByScope($this->element->getElementType(),
'visibleInMail');
151 $visibility = (bool)$this->userConfiguredElementTyposcript[
'visibleInMail'];
154 $this->element->setShowElement($visibility);
165 foreach ($this->htmlAttributes as $attributeName => $attributeValue) {
166 if (strpos($attributeName,
'-*') > 0) {
167 $prefix = substr($attributeName, 0, -1);
168 $this->wildcardPrefixes[] = $prefix;
169 unset($this->htmlAttributes[$attributeName]);
184 foreach ($this->htmlAttributes as $attributeName => $attributeValue) {
185 $attributeNameWithoutDot = rtrim($attributeName,
'.');
186 $attributeNameToSet = $attributeNameWithoutDot;
189 if ($this->
arrayKeyExists($attributeName, $this->userConfiguredElementTyposcript)) {
190 if ($this->formBuilder->getConfiguration()->getCompatibility()) {
191 $newAttributeName = $this->formBuilder->getCompatibilityService()->getNewAttributeName(
192 $this->element->getElementType(),
193 $attributeNameWithoutDot
196 if ($newAttributeName !== $attributeNameWithoutDot) {
197 $attributeNameToSet = $newAttributeName;
199 if ($this->
arrayKeyExists($newAttributeName, $this->userConfiguredElementTyposcript)) {
200 $attributeValue = $this->formBuilder->getFormUtility()->renderItem(
201 $this->userConfiguredElementTyposcript[$newAttributeName .
'.'],
202 $this->userConfiguredElementTyposcript[$newAttributeName]
205 $this->htmlAttributes[$newAttributeName] = $attributeValue;
207 unset($this->userConfiguredElementTyposcript[$newAttributeName .
'.']);
208 unset($this->userConfiguredElementTyposcript[$newAttributeName]);
214 if ($rendered ===
false) {
215 if ($this->
arrayKeyExists($attributeNameWithoutDot, $this->userConfiguredElementTyposcript)) {
216 $attributeValue = $this->formBuilder->getFormUtility()->renderItem(
217 $this->userConfiguredElementTyposcript[$attributeNameWithoutDot .
'.'],
218 $this->userConfiguredElementTyposcript[$attributeNameWithoutDot]
220 $this->htmlAttributes[$attributeNameToSet] = $attributeValue;
223 unset($this->userConfiguredElementTyposcript[$attributeNameWithoutDot .
'.']);
224 unset($this->userConfiguredElementTyposcript[$attributeNameWithoutDot]);
228 $ignoreKeys = array();
229 foreach ($this->userConfiguredElementTyposcript as $attributeName => $attributeValue) {
233 || isset($ignoreKeys[$attributeName])
235 $ignoreKeys[$attributeName .
'.'] =
true;
239 foreach ($this->wildcardPrefixes as $wildcardPrefix) {
240 if (strpos($attributeName, $wildcardPrefix) !== 0) {
243 $attributeNameWithoutDot = rtrim($attributeName,
'.');
244 $attributeValue = $this->formBuilder->getFormUtility()->renderItem(
245 $this->userConfiguredElementTyposcript[$attributeNameWithoutDot .
'.'],
246 $this->userConfiguredElementTyposcript[$attributeNameWithoutDot]
248 $this->htmlAttributes[$attributeNameWithoutDot] = $attributeValue;
249 $ignoreKeys[$attributeNameWithoutDot .
'.'] =
true;
250 unset($this->userConfiguredElementTyposcript[$attributeNameWithoutDot .
'.']);
251 unset($this->userConfiguredElementTyposcript[$attributeNameWithoutDot]);
265 $fixedHtmlAttributeValues = $this->typoScriptRepository->getModelConfigurationByScope($this->element->getElementType(),
'fixedHtmlAttributeValues.');
266 if (is_array($fixedHtmlAttributeValues)) {
267 foreach ($fixedHtmlAttributeValues as $attributeName => $attributeValue) {
268 $this->htmlAttributes[$attributeName] = $attributeValue;
281 $htmlAttributesUsedByTheViewHelperDirectly = $this->typoScriptRepository->getModelConfigurationByScope($this->element->getElementType(),
'htmlAttributesUsedByTheViewHelperDirectly.');
282 if (is_array($htmlAttributesUsedByTheViewHelperDirectly)) {
283 foreach ($htmlAttributesUsedByTheViewHelperDirectly as $attributeName) {
284 if (array_key_exists($attributeName, $this->htmlAttributes)) {
285 $this->additionalArguments[$attributeName] = $this->htmlAttributes[$attributeName];
286 unset($this->htmlAttributes[$attributeName]);
299 $viewHelperDefaultArguments = $this->typoScriptRepository->getModelConfigurationByScope($this->element->getElementType(),
'viewHelperDefaultArguments.');
300 if (is_array($viewHelperDefaultArguments)) {
301 foreach ($viewHelperDefaultArguments as $viewHelperDefaulArgumentName => $viewHelperDefaulArgumentValue) {
302 $this->additionalArguments[$viewHelperDefaulArgumentName] = $viewHelperDefaulArgumentValue;
305 unset($this->userConfiguredElementTyposcript[
'viewHelperDefaultArguments']);
316 $ignoreKeys = array();
317 foreach ($this->userConfiguredElementTyposcript as $attributeName => $attributeValue) {
321 || isset($ignoreKeys[$attributeName])
322 || $attributeName ==
'postProcessor.'
323 || $attributeName ==
'rules.'
324 || $attributeName ==
'filters.'
325 || $attributeName ==
'layout'
327 $ignoreKeys[$attributeName .
'.'] =
true;
330 $attributeNameWithoutDot = rtrim($attributeName,
'.');
331 $attributeNameToSet = $attributeNameWithoutDot;
333 if ($this->formBuilder->getConfiguration()->getCompatibility()) {
334 $newAttributeName = $this->formBuilder->getCompatibilityService()->getNewAttributeName(
335 $this->element->getElementType(),
336 $attributeNameWithoutDot
339 if ($newAttributeName !== $attributeNameWithoutDot) {
340 $attributeNameToSet = $newAttributeName;
342 if ($this->
arrayKeyExists($newAttributeName, $this->userConfiguredElementTyposcript)) {
343 $attributeValue = $this->formBuilder->getFormUtility()->renderItem(
344 $this->userConfiguredElementTyposcript[$newAttributeName .
'.'],
345 $this->userConfiguredElementTyposcript[$newAttributeName]
348 $this->additionalArguments[$newAttributeName] = $attributeValue;
350 $ignoreKeys[$newAttributeName .
'.'] =
true;
351 $ignoreKeys[$newAttributeName] =
true;
352 unset($this->userConfiguredElementTyposcript[$newAttributeName .
'.']);
353 unset($this->userConfiguredElementTyposcript[$newAttributeName]);
358 if ($rendered ===
false) {
359 $attributeValue = $this->formBuilder->getFormUtility()->renderItem(
360 $this->userConfiguredElementTyposcript[$attributeNameWithoutDot .
'.'],
361 $this->userConfiguredElementTyposcript[$attributeNameWithoutDot]
363 $this->additionalArguments[$attributeNameToSet] = $attributeValue;
364 $ignoreKeys[$attributeNameToSet .
'.'] =
true;
365 $ignoreKeys[$attributeNameToSet] =
true;
367 unset($this->userConfiguredElementTyposcript[$attributeNameWithoutDot .
'.']);
368 unset($this->userConfiguredElementTyposcript[$attributeNameWithoutDot]);
373 !$this->formBuilder->getConfiguration()->getContentElementRendering()
374 && $this->element->getElementType() ==
'FORM'
376 unset($this->additionalArguments[
'stdWrap']);
377 unset($this->additionalArguments[
'stdWrap.']);
389 $this->element->getParentElement()
390 && (int)$this->typoScriptRepository->getModelConfigurationByScope($this->element->getParentElement()->getElementType(),
'childrenInheritName') == 1
392 $this->htmlAttributes[
'name'] = $this->element->getParentElement()->getName();
393 $this->additionalArguments[
'multiple'] =
'1';
395 $this->element->setName($name);
398 $this->element->setName($this->htmlAttributes[
'name']);
401 $this->element->setId($this->htmlAttributes[
'id']);
417 $name = $this->formBuilder->getFormUtility()->sanitizeNameAttribute($name);
419 $name =
'id-' . $this->element->getElementCounter();
438 $id = $this->formBuilder->getFormUtility()->sanitizeIdAttribute($id);
440 $id =
'field-' . $this->element->getElementCounter();
455 isset($haystack[$needle]) || isset($haystack[$needle .
'.'])