Skip to content
Snippets Groups Projects
Commit 8b5d30d7 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Correct implementation of the form handling

parent 2956afd2
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,8 @@ class FormsFinisher extends AbstractFinisher {
}
$markers = [];
$markerLabels = [];
foreach ($formValues as $identifier => $value) {
$formElement = $formDefinition->getElementByIdentifier($identifier);
if (!$formElement) {
......@@ -83,11 +85,18 @@ class FormsFinisher extends AbstractFinisher {
}
$formElementProperties = $formElement->getProperties();
$markerNameArray = [];
if (isset($formElementProperties['markerName']) && \trim($formElementProperties['markerName']) !== '') {
$markerName = \trim($formElementProperties['markerName']);
$markerNameArray = GeneralUtility::trimExplode(',', \trim($formElementProperties['markerName']), FALSE, 2);
$markerName = $markerNameArray[0];
} else {
$markerNameArray[0] = $identifier;
$markerNameArray[1] = $identifier;
$markerName = $identifier;
}
$markerLabels[$markerNameArray[0]] = $markerNameArray[1];
$markerName = RegisterService::normalizeFormFieldMarkerName($markerName);
$markers[$markerName] = $value;
}
......@@ -102,7 +111,7 @@ class FormsFinisher extends AbstractFinisher {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$mailTemplateService = $objectManager->get(
MailTemplateService::class, $templateName, $extensionKey, $markers
MailTemplateService::class, $templateName, $extensionKey, $markers, $markerLabels
);
$ignoreMailQueue = (boolean) $this->parseOption('ignoreMailQueue');
......
......@@ -115,6 +115,11 @@ class MailTemplateService {
*/
private $markers;
/**
* @var array $markerLabels
*/
private $markerLabels;
/**
* @var string $bccAddresses
*/
......@@ -156,12 +161,14 @@ class MailTemplateService {
* @param string $templateName
* @param string $extensionKey
* @param array $markers
* @param array $markerLabels
* @throws \InvalidArgumentException
*/
public function __construct($templateName = '', $extensionKey = '', $markers = []) {
public function __construct($templateName = '', $extensionKey = '', $markers = [], $markerLabels = []) {
$this->templateName = $templateName;
$this->extensionKey = $extensionKey;
$this->markers = $markers;
$this->markerLabels = $markerLabels;
/** @var ObjectManager objectManager */
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
......@@ -839,6 +846,9 @@ class MailTemplateService {
$allMarker = '';
foreach ($markers as $key => $value) {
if (\array_key_exists($key, $this->markerLabels)) {
$key = $this->markerLabels[$key];
}
if (\is_string($value)) {
$allMarker .= $key . ': ' . $value . PHP_EOL;
} elseif (\is_array($value)) {
......
......@@ -257,7 +257,8 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
'marker' => $markerName,
'type' => MailTemplateService::MARKER_TYPE_STRING,
'value' => $marker['value'],
'description' => $marker['description']
'description' => $marker['description'],
'markerLabel' => $marker['markerLabel']
];
}
......
......@@ -144,21 +144,23 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
$markers = [];
foreach ($renderables as $element) {
// if markerName is explicitly set, override the registered identifier
$markerName = '';
$markerArray = [];
if (isset($element['properties']['markerName']) && $element['properties']['markerName'] !== '') {
$markerArray = GeneralUtility::trimExplode(',', $element['properties']['markerName'], FALSE, 2);
$markerName = $markerArray[0];
}
$markerName = RegisterService::normalizeFormFieldMarkerName($markerName);
$identifier = $markerArray[1] ?? $markerArray[0];
$markerLabel = $markerArray[0];
if (isset($markerArray[1])) {
$markerLabel = $markerArray[1];
}
$markers[$markerName] = [
'identifier' => $identifier,
'identifier' => $markerName,
'type' => MailTemplateService::MARKER_TYPE_STRING,
'value' => $element['label'],
'description' => $element['label']
'description' => $element['label'],
'markerLabel' => $markerLabel
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment