Commit ac5026b5 authored by Kevin von Spiczak's avatar Kevin von Spiczak
Browse files

[FEATURE] pre-fill the template field, if empty

https://trello.com/c/bFMJWmLu/2251-sgmail-sgforms-anpassungen
If no custom template key was entered by the editor, a mix of the form & finisher identifier was used, to uniquely identify the mail template. This commit makes sure this value is also saved in the form configuration, so that the editor immediately sees the generated template name in the backend form editor.
parent 873b3fe4
......@@ -68,8 +68,6 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
*/
public function saveFormAction(string $formPersistenceIdentifier, FormDefinitionArray $formDefinition) {
$registrationService = $this->objectManager->get(RegisterService::class);
/** @noinspection PhpInternalEntityUsedInspection */
parent::saveFormAction($formPersistenceIdentifier, $formDefinition);
// immediately exit when no finisher is defined (that means no sgmail integration anyway)
if (!$formDefinition['finishers']) {
......@@ -78,7 +76,7 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
/** @var array $finishers */
$finishers = $formDefinition['finishers'];
foreach ($finishers as $finisher) {
foreach ($finishers as $key => $finisher) {
if (!\in_array($finisher['identifier'], self::MAIL_FINISHER, TRUE)) {
continue;
}
......@@ -92,6 +90,8 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
$templateKey = $finisher['options']['template'];
if ($templateKey === '') {
$templateKey = $formDefinition['identifier'] . '-' . $finisher['identifier'];
// pre-fill the template key field, since no custom key was defined by the editor
$formDefinition['finishers'][$key]['options']['template'] = $templateKey;
}
// if there was no sg mail finisher or an missing key then simply exit the function
......@@ -128,6 +128,10 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
$this->writeRegisterFile($renderables, $extensionKey, $templateKey);
}
// call parent::saveFormAction() at the end, in order to save our changes to the $formDefinition
/** @noinspection PhpInternalEntityUsedInspection */
parent::saveFormAction($formPersistenceIdentifier, $formDefinition);
// call register function in register service class
$registrationService->clearCaches();
$registrationService->getRegisterArray();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment