From 8cd0ba21a38883dc9d5f9e89d53705012c4378a3 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 31 Jul 2016 18:15:37 +0200 Subject: [PATCH] Change validation order of menu item fields Fields should generally be validated in the order in which they are presented to the user. --- .../lib/acp/form/MenuItemAddForm.class.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php index 3023d99b0f..3cc0b31365 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php @@ -166,6 +166,24 @@ class MenuItemAddForm extends AbstractForm { public function validate() { parent::validate(); + // validate parent menu item + if ($this->parentItemID) { + $parentMenuItem = new MenuItem($this->parentItemID); + if (!$parentMenuItem->itemID || $parentMenuItem->menuID != $this->menuID) { + throw new UserInputException('parentItemID', 'invalid'); + } + } + + // validate page menu item name + if (!I18nHandler::getInstance()->validateValue('title')) { + if (I18nHandler::getInstance()->isPlainValue('title')) { + throw new UserInputException('title'); + } + else { + throw new UserInputException('title', 'multilingual'); + } + } + // validate menu item controller if ($this->isInternalLink) { $this->externalURL = ''; @@ -199,24 +217,6 @@ class MenuItemAddForm extends AbstractForm { throw new UserInputException('externalURL'); } } - - // validate page menu item name - if (!I18nHandler::getInstance()->validateValue('title')) { - if (I18nHandler::getInstance()->isPlainValue('title')) { - throw new UserInputException('title'); - } - else { - throw new UserInputException('title', 'multilingual'); - } - } - - // validate parent menu item - if ($this->parentItemID) { - $parentMenuItem = new MenuItem($this->parentItemID); - if (!$parentMenuItem->itemID || $parentMenuItem->menuID != $this->menuID) { - throw new UserInputException('parentItemID', 'invalid'); - } - } } /** -- 2.20.1