[BUGFIX] TCA Tree should respect requestUpdate and type
authorMarco Huber <mail@marco-huber.de>
Thu, 24 Mar 2011 08:50:04 +0000 (09:50 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Fri, 8 Jul 2011 13:51:17 +0000 (15:51 +0200)
TCA Tree should respect $TCA['myTable']['ctrl']['requestUpdate']
and $TCA['myTable']['type'], but the onChange Javascript is missing.

Change-Id: I46b9513413cbb61660609bbf73eb3551c5ce7a24
Resolves: #25382
Reviewed-on: http://review.typo3.org/1251
Reviewed-by: Stefan Neufeind
Reviewed-by: Fabien Udriot
Reviewed-by: Steffen Ritter
Tested-by: Thorsten Kahler
Tested-by: Steffen Ritter
t3lib/tceforms/class.t3lib_tceforms_tree.php

index d20b389..a281351 100644 (file)
@@ -63,6 +63,7 @@ class t3lib_TCEforms_Tree {
         * @return string The HTML code for the TCEform field
         */
        public function renderField($table, $field, $row, &$PA, $config, $possibleSelectboxItems, $noMatchLabel) {
+
                $valueArray = array();
                $selectedNodes = array();
 
@@ -144,7 +145,21 @@ class t3lib_TCEforms_Tree {
 
                $onChange = '';
                if ($PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged']) {
-                       $onChange = substr($PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'], 0, -1);
+                       $onChange = $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
+               }
+
+                       // Create a JavaScript code line which will ask the user to save/update the form due to changing the element.
+                       // This is used for eg. "type" fields and others configured with "requestUpdate"
+               if (($GLOBALS['TCA'][$table]['ctrl']['type']
+                                       && !strcmp($field, $GLOBALS['TCA'][$table]['ctrl']['type']))
+                               || ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate']
+                                       && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $field))) {
+                       if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
+                               $onChange .= 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && ' .
+                                       'TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
+                       } else {
+                               $onChange .= 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
+                       }
                }
 
                /** @var $pageRenderer t3lib_PageRenderer */