Skip to content

Commit 02f56e9

Browse files
authored
Merge pull request #6413 from WoltLab/6.2-bugfix-label-without-label-group
Check that at least one label group exists
2 parents a9599e0 + ba248f5 commit 02f56e9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

wcfsetup/install/files/lib/acp/form/LabelAddForm.class.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
use wcf\data\label\LabelAction;
88
use wcf\data\label\LabelList;
99
use wcf\form\AbstractFormBuilderForm;
10+
use wcf\system\exception\NamedUserException;
1011
use wcf\system\form\builder\container\FormContainer;
1112
use wcf\system\form\builder\field\BadgeColorFormField;
1213
use wcf\system\form\builder\field\IFormField;
1314
use wcf\system\form\builder\field\IntegerFormField;
1415
use wcf\system\form\builder\field\SelectFormField;
1516
use wcf\system\form\builder\field\ShowOrderFormField;
1617
use wcf\system\form\builder\field\TextFormField;
18+
use wcf\system\WCF;
19+
use wcf\util\HtmlString;
1720

1821
/**
1922
* Shows the label add form.
@@ -51,12 +54,20 @@ protected function createForm()
5154
{
5255
parent::createForm();
5356

57+
$labelGroupList = new LabelGroupList();
58+
$labelGroupList->readObjects();
59+
if ($labelGroupList->count() === 0) {
60+
throw new NamedUserException(
61+
HtmlString::fromSafeHtml(WCF::getLanguage()->getDynamicVariable('wcf.acp.label.error.noGroups'))
62+
);
63+
}
64+
5465
$this->form->appendChildren([
5566
FormContainer::create('section')
5667
->appendChildren([
5768
SelectFormField::create('groupID')
5869
->label('wcf.acp.label.group')
59-
->options(new LabelGroupList())
70+
->options($labelGroupList)
6071
->immutable($this->formAction !== 'create')
6172
->description('wcf.acp.label.group.permanentSelection')
6273
->required(),

0 commit comments

Comments
 (0)