[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)
committerJigal van Hemert <jigal@xs4all.nl>
Sun, 28 Aug 2011 15:51:58 +0000 (17:51 +0200)
TCA Tree should respect $TCA['myTable']['ctrl']['requestUpdate']
and $TCA['myTable']['type'], but the onChange Javascript is missing.

Change-Id: If2c7997c9627249e3f643c9670a2a9d4ba94103a
Resolves: #25382
Reviewed-on: http://review.typo3.org/3402
Reviewed-by: Lars Trebing
Tested-by: Lars Trebing
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/tceforms/class.t3lib_tceforms_tree.php

index d1a0c4f..51a28f3 100644 (file)
@@ -65,6 +65,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();
 
@@ -146,7 +147,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 */