[BUGFIX] EXT:Scheduler: Post only fields of selected class on save 27/51027/3
authorMichael Oehlhof <typo3@oehlhof.de>
Thu, 22 Dec 2016 16:08:45 +0000 (17:08 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 26 Mar 2017 11:40:05 +0000 (13:40 +0200)
When saving a new task, now only the extra fields of the selected class
where submitted via post and no longer all extra fields of all possible
classes.
This prevents saving the wrong value if extra fields of different classes
have the same id.

Resolves: #25805
Releases: master
Change-Id: I4f0ae67694fbc3b284e763e3edd123804d078350
Reviewed-on: https://review.typo3.org/51027
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js

index 2502427..f1b88eb 100644 (file)
@@ -162,7 +162,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
             // Prepare main content
             $this->content .= '<h1>' . $this->getLanguageService()->getLL('function.' . $this->MOD_SETTINGS['function']) . '</h1>';
             $this->content .= $this->getModuleContent();
-            $this->content .= '</form>';
+            $this->content .= '</form><div id="extraFieldsHidden"></div>';
         } else {
             // If no access, only display the module's title
             $this->content = '<h1>' . $this->getLanguageService()->getLL('title.') . '</h1>';
@@ -800,6 +800,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
             . '</div></div>';
 
         // Display additional fields
+        $table[] = '<div id="extraFieldsSection">';
         foreach ($allAdditionalFields as $class => $fields) {
             if ($class == $taskInfo['class']) {
                 $additionalFieldsStyle = '';
@@ -820,6 +821,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                 }
             }
         }
+        $table[] = '</div>';
 
         $this->view->assign('table', implode(LF, $table));
         $this->view->assign('now', $this->getServerTime());
index 92017b5..3e364a0 100644 (file)
@@ -14,7 +14,9 @@
 /**
  * Module: TYPO3/CMS/Scheduler/Scheduler
  */
-define(['jquery'], function($) {
+define(['jquery',
+               'TYPO3/CMS/Backend/SplitButtons'
+               ], function($, SplitButtons) {
 
        /**
         *
@@ -168,5 +170,13 @@ define(['jquery'], function($) {
        $(Scheduler.initializeEvents);
        $(Scheduler.initializeDefaultStates);
 
+       SplitButtons.addPreSubmitCallback(function() {
+               var taskClass = $('#task_class').val();
+               taskClass = taskClass.toLowerCase().replace(/\\/g, '-');
+
+               $('.extraFields').appendTo($('#extraFieldsHidden'));
+               $('.extra_fields_' + taskClass).appendTo($('#extraFieldsSection'));
+       });
+
        return Scheduler;
 });