Preserve the label selection on validation errors
authorAlexander Ebert <ebert@woltlab.com>
Thu, 28 Sep 2023 22:11:18 +0000 (00:11 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 5 Oct 2023 15:22:51 +0000 (17:22 +0200)
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php

index 5587f21e779283337219f62c23326ab3f7b1fb64..c39dd2445060878104f2bc7977ab46b3ea5d3a3a 100644 (file)
@@ -477,14 +477,6 @@ class ArticleAddForm extends AbstractForm
         // reset category ids to accessible category ids
         ArticleLabelObjectHandler::getInstance()->setCategoryIDs(ArticleCategory::getAccessibleCategoryIDs());
 
-        if (!empty($validationResult[0])) {
-            throw new UserInputException('labelIDs');
-        }
-
-        if (!empty($validationResult)) {
-            throw new UserInputException('label', $validationResult);
-        }
-
         foreach ($this->labelIDs as $groupID => $labelID) {
             foreach ($this->labelPickers as $labelPicker) {
                 if ($labelPicker->labelGroup->groupID == $groupID) {
@@ -492,6 +484,14 @@ class ArticleAddForm extends AbstractForm
                 }
             }
         }
+
+        if (!empty($validationResult[0])) {
+            throw new UserInputException('labelIDs');
+        }
+
+        if (!empty($validationResult)) {
+            throw new UserInputException('label', $validationResult);
+        }
     }
 
     /**
@@ -668,7 +668,6 @@ class ArticleAddForm extends AbstractForm
             'availableLanguages' => $this->availableLanguages,
             'categoryNodeList' => (new CategoryNodeTree('com.woltlab.wcf.article.category'))->getIterator(),
             'accessibleCategoryIDs' => ArticleCategory::getAccessibleCategoryIDs(),
-            'labelIDs' => $this->labelIDs,
             'labelGroupsToCategories' => $this->labelGroupsToCategories,
             'labelPickers' => $this->labelPickers,
             'attachmentHandler' => $this->attachmentHandler,