From: Matthias Schmidt Date: Sun, 31 Jul 2016 16:15:37 +0000 (+0200) Subject: Change validation order of menu item fields X-Git-Tag: 3.0.0_Beta_1~834 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8cd0ba21a38883dc9d5f9e89d53705012c4378a3;p=GitHub%2FWoltLab%2FWCF.git Change validation order of menu item fields Fields should generally be validated in the order in which they are presented to the user. --- 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'); - } - } } /**