2 namespace TYPO3\CMS\Form\Domain\Builder;
46 $formBuilder = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(FormBuilder::class);
47 $formBuilder->setConfiguration($configuration);
170 $this->compatibilityService = CompatibilityLayerUtility::create($this);
261 $userConfiguredFormTypoScript = $this->configuration->getTypoScript();
263 if ($this->configuration->getCompatibility()) {
265 if (isset($userConfiguredFormTypoScript[
'layout.'])) {
266 $layout = $userConfiguredFormTypoScript[
'layout.'];
268 $this->configuration->setThemeName(static::COMPATIBILITY_THEME_NAME);
269 unset($userConfiguredFormTypoScript[
'layout.']);
274 $actionLayoutKey =
'form.';
277 $actionLayoutKey =
'confirmation.';
280 $actionLayoutKey =
'postProcessor.';
283 $actionLayoutKey =
'';
286 if ($actionLayoutKey && isset($userConfiguredFormTypoScript[$actionLayoutKey][
'layout.'])) {
287 $actionLayout = $userConfiguredFormTypoScript[$actionLayoutKey][
'layout.'];
288 $this->configuration->setThemeName(static::COMPATIBILITY_THEME_NAME);
289 unset($userConfiguredFormTypoScript[$actionLayoutKey][
'layout.']);
290 $layout = array_replace_recursive($layout, $actionLayout);
293 if (!empty($layout)) {
294 $this->compatibilityService->setGlobalLayoutConfiguration($layout);
299 $this->
reviveElement($form, $userConfiguredFormTypoScript,
'FORM');
300 $form->setThemeName($this->configuration->getThemeName());
327 if ($elementType ===
'IMAGEBUTTON') {
334 $elementBuilder = ElementBuilder::create($this, $element, $userConfiguredElementTypoScript);
335 $elementBuilder->setPartialPaths();
336 $elementBuilder->setVisibility();
339 $attributeValue =
'';
340 if ($this->configuration->getContentElementRendering()) {
341 $attributeValue = $this->formUtility->renderItem(
342 $userConfiguredElementTypoScript[
'cObj.'],
343 $userConfiguredElementTypoScript[
'cObj']
347 'content' => $attributeValue,
350 if ($this->configuration->getCompatibility()) {
351 $this->compatibilityService->setElementLayouts($element, $userConfiguredElementTypoScript);
352 if (isset($userConfiguredElementTypoScript[
'layout'])) {
353 $this->configuration->setThemeName(static::COMPATIBILITY_THEME_NAME);
354 unset($userConfiguredElementTypoScript[
'layout']);
358 $this->
setAttributes($elementBuilder, $element, $userConfiguredElementTypoScript);
359 $userConfiguredElementTypoScript = $elementBuilder->getUserConfiguredElementTypoScript();
360 $this->setValidationMessages($element);
362 if ($this->configuration->getCompatibility()) {
363 $this->compatibilityService->setElementLayouts($element, $userConfiguredElementTypoScript);
364 if (isset($userConfiguredElementTypoScript[
'layout'])) {
365 $this->configuration->setThemeName(static::COMPATIBILITY_THEME_NAME);
366 unset($userConfiguredElementTypoScript[
'layout']);
369 $this->signalSlotDispatcher->dispatch(
371 'txFormAfterElementCreation',
372 array($element, $this)
390 if (is_array($userConfiguredElementTypoScript)) {
392 foreach ($keys as $key) {
395 && strpos($key,
'.') ===
false
397 $elementType = $userConfiguredElementTypoScript[$key];
398 if (isset($userConfiguredElementTypoScript[$key .
'.'])) {
399 $concreteChildElementTypoScript = $userConfiguredElementTypoScript[$key .
'.'];
401 $concreteChildElementTypoScript = array();
407 throw new \InvalidArgumentException(
'Container element with id=' . $element->
getElementCounter() .
' has no configuration which means no children.', 1333754854);
424 if (in_array($elementType, $this->typoScriptRepository->getRegisteredElementTypes())) {
425 $this->
addChildElement($element, $userConfiguredElementTypoScript, $elementType);
426 }
elseif ($this->configuration->getContentElementRendering()) {
427 $contentObject = array(
428 'cObj' => $elementType,
429 'cObj.' => $userConfiguredElementTypoScript
446 $childElement->setParentElement($element);
448 $this->
reviveElement($childElement, $userConfiguredElementTypoScript, $elementType);
461 $htmlAttributes = $this->typoScriptRepository->getModelDefinedHtmlAttributes($element->
getElementType());
475 $userConfiguredElementTypoScript = $elementBuilder->getUserConfiguredElementTypoScript();
478 $additionalArguments = $this->typoScriptService->convertTypoScriptArrayToPlainArray($additionalArguments);
479 $additionalArguments[
'prefix'] = $this->configuration->getPrefix();
504 $this->sessionUtility->getSessionData($element->
getName())
523 $elementName = $element->
getName();
530 if ($this->
getIncomingData()->getIncomingField($elementName) !== null) {
533 $userConfiguredElementTypoScript[
'filters.'][-1] =
'removexss';
535 foreach ($keys as $key) {
536 $class = $userConfiguredElementTypoScript[
'filters.'][$key];
539 && strpos($key,
'.') ===
false
541 $filterArguments = $userConfiguredElementTypoScript[
'filters.'][$key .
'.'];
542 $filterClassName = $this->typoScriptRepository->getRegisteredClassName((
string)$class,
'registeredFilters');
543 if ($filterClassName !== null) {
545 if (is_string($this->
getIncomingData()->getIncomingField($elementName))) {
546 if (is_null($filterArguments)) {
547 $filter = $this->objectManager->get($filterClassName);
549 $filter = $this->objectManager->get($filterClassName, $filterArguments);
552 $value = $filter->filter($this->
getIncomingData()->getIncomingField($elementName));
555 throw new \RuntimeException(
'Class "' . $filterClassName .
'" could not be loaded.');
559 throw new \RuntimeException(
'Class "' . $filterClassName .
'" not registered via TypoScript.');
570 $this->signalSlotDispatcher->dispatch(
572 'txFormHandleIncomingValues',
589 protected function setValidationMessages(
Element $element)
591 $elementName = $element->
getName();
592 $mandatoryMessages = $this->validationBuilder->getMandatoryValidationMessagesByElementName($elementName);
600 $errorMessages = array();
601 foreach ($errors as $error) {
602 $errorMessages[] = $error->getMessage();
615 return $this->configuration->getPrefix();
625 return !$this->configuration->getContentElementRendering();
635 return $this->controllerContext->getRequest()->getControllerActionName();
645 return $this->configuration->getCompatibility();
655 return $this->controllerContext->getValidationElement();