Fixed issue when editing articles without tags
authorMarcel Werk <burntime@woltlab.com>
Sun, 19 Jul 2020 15:27:51 +0000 (17:27 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 19 Jul 2020 15:27:51 +0000 (17:27 +0200)
com.woltlab.wcf/templates/articleAdd.tpl
wcfsetup/install/files/acp/templates/articleAdd.tpl
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php

index 2098e7b0c6ba3c2ee5db0e9750c7347b85273d01..9ba2864b79c4a9b7de94b4665f617efad13ceeef 100644 (file)
                        </dl>
                        
                        {if MODULE_TAGGING}
-                               {if !$tags[0]|empty}
-                                       {include file='tagInput' tagInputSuffix='0' tagSubmitFieldName='tags[0][]' tags=$tags[0] sandbox=true}
-                               {else}
-                                       {include file='tagInput' tagInputSuffix='0' tagSubmitFieldName='tags[0][]' sandbox=true}
-                               {/if}
+                               {include file='tagInput' tagInputSuffix='0' tagSubmitFieldName='tags[0][]' tags=$tags[0] sandbox=true}
                        {/if}
                        
                        {event name='informationFields'}
                                                
                                                {if MODULE_TAGGING}
                                                        {assign var='tagSubmitFieldName' value='tags['|concat:$availableLanguage->languageID:'][]'}
-                                                       {if !$tags[$availableLanguage->languageID]|empty}
-                                                               {include file='tagInput' tagInputSuffix=$availableLanguage->languageID tagSubmitFieldName=$tagSubmitFieldName tags=$tags[$availableLanguage->languageID] sandbox=true}
-                                                       {else}
-                                                               {include file='tagInput' tagInputSuffix=$availableLanguage->languageID tagSubmitFieldName=$tagSubmitFieldName sandbox=true}
-                                                       {/if}
+                                                       {include file='tagInput' tagInputSuffix=$availableLanguage->languageID tagSubmitFieldName=$tagSubmitFieldName tags=$tags[$availableLanguage->languageID] sandbox=true}
                                                {/if}
                                                
                                                {event name='informationFieldsMultilingual'}
index 2098e7b0c6ba3c2ee5db0e9750c7347b85273d01..9ba2864b79c4a9b7de94b4665f617efad13ceeef 100644 (file)
                        </dl>
                        
                        {if MODULE_TAGGING}
-                               {if !$tags[0]|empty}
-                                       {include file='tagInput' tagInputSuffix='0' tagSubmitFieldName='tags[0][]' tags=$tags[0] sandbox=true}
-                               {else}
-                                       {include file='tagInput' tagInputSuffix='0' tagSubmitFieldName='tags[0][]' sandbox=true}
-                               {/if}
+                               {include file='tagInput' tagInputSuffix='0' tagSubmitFieldName='tags[0][]' tags=$tags[0] sandbox=true}
                        {/if}
                        
                        {event name='informationFields'}
                                                
                                                {if MODULE_TAGGING}
                                                        {assign var='tagSubmitFieldName' value='tags['|concat:$availableLanguage->languageID:'][]'}
-                                                       {if !$tags[$availableLanguage->languageID]|empty}
-                                                               {include file='tagInput' tagInputSuffix=$availableLanguage->languageID tagSubmitFieldName=$tagSubmitFieldName tags=$tags[$availableLanguage->languageID] sandbox=true}
-                                                       {else}
-                                                               {include file='tagInput' tagInputSuffix=$availableLanguage->languageID tagSubmitFieldName=$tagSubmitFieldName sandbox=true}
-                                                       {/if}
+                                                       {include file='tagInput' tagInputSuffix=$availableLanguage->languageID tagSubmitFieldName=$tagSubmitFieldName tags=$tags[$availableLanguage->languageID] sandbox=true}
                                                {/if}
                                                
                                                {event name='informationFieldsMultilingual'}
index ac1f7dc9910ecdbbdc46f7d46375d8c48d31db31..65c7aa9e924f7b6b30df84818f1d42f996eca17c 100644 (file)
@@ -478,6 +478,16 @@ class ArticleAddForm extends AbstractForm {
                if (empty($_POST)) {
                        $this->setDefaultValues();
                }
+               
+               // init tags
+               if (!$this->isMultilingual) {
+                       if (!isset($this->tags[0])) $this->tags[0] = [];
+               }
+               else {
+                       foreach ($this->availableLanguages as $language) {
+                               if (!isset($this->tags[$language->languageID])) $this->tags[$language->languageID] = [];
+                       }
+               }
        }
        
        /**