From 2d4a1fafbf9fc9164da8e247664d31595876aa80 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 15 Dec 2013 20:40:42 +0100 Subject: [PATCH] Fixes issues in UserGroupOptionForm --- .../files/acp/templates/userGroupOption.tpl | 16 ++++++++++++++-- .../lib/acp/form/UserGroupOptionForm.class.php | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/userGroupOption.tpl b/wcfsetup/install/files/acp/templates/userGroupOption.tpl index 3bd1d90fe3..14b94387ae 100644 --- a/wcfsetup/install/files/acp/templates/userGroupOption.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupOption.tpl @@ -5,8 +5,20 @@ $('#optionValueContainer label').each(function(index, label) { var $label = $(label); var $id = $label.prop('for'); - var $groupID = $id.replace(/^userGroupOption/, ''); - $label.parents('dl').children('dd').find('input, select, textarea').attr('id', $id).attr('name', 'values[' + $groupID + ']'); + if ($id && $id.match(/^userGroupOption/)) { + var $groupID = $id.replace(/^userGroupOption/, ''); + $label.parents('dl').children('dd').find('input, select, textarea').each(function(index, element) { + var $element = $(element); + var $oldName = $element.attr('name'); + + var $newName = 'values[' + $groupID + ']'; + if ($oldName.substr(-2) == '[]') { + $newName += '[]'; + } + + $element.attr('id', $id).attr('name', $newName); + }); + } }); }); diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php index cdd08bbceb..1b7059b0ad 100644 --- a/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php @@ -144,11 +144,13 @@ class UserGroupOptionForm extends AbstractForm { parent::validate(); // validate option values - foreach ($this->values as $groupID => $optionValue) { + foreach ($this->values as $groupID => &$optionValue) { if (!isset($this->groups[$groupID])) { throw new PermissionDeniedException(); } + $optionValue = $this->optionType->getData($this->userGroupOption, $optionValue); + try { $this->optionType->validate($this->userGroupOption, $optionValue); } -- 2.20.1