Skip to content

Commit f31cd88

Browse files
authored
Merge pull request #6619 from WoltLab/62-show-order-form-field-fix
`ShowOrderFormField` includes edited object in sibling list
2 parents 68a12e8 + 2c37c3c commit f31cd88

8 files changed

+73
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function getOptionTypeFormField(): SelectFormField
9292
/**
9393
* @return array<int, string>
9494
*/
95-
private function getContactOptions(): array
95+
protected function getContactOptions(): array
9696
{
9797
$optionList = new ContactOptionList();
9898
$optionList->sqlOrderBy = 'showOrder ASC';

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ public function assignVariables()
7070
),
7171
]);
7272
}
73+
74+
#[\Override]
75+
protected function getContactOptions(): array
76+
{
77+
return \array_filter(
78+
parent::getContactOptions(),
79+
fn(int $key) => $key !== $this->formObject->getObjectID(),
80+
\ARRAY_FILTER_USE_KEY
81+
);
82+
}
7383
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ protected function createForm()
8181
/**
8282
* @return array<int, string>
8383
*/
84-
private function getContactRecipient(): array
84+
protected function getContactRecipient(): array
8585
{
8686
$recipientList = new ContactRecipientList();
8787
$recipientList->sqlOrderBy = 'showOrder ASC';
8888
$recipientList->readObjects();
8989

90-
return \array_map(static fn ($recipient) => $recipient->getName(), $recipientList->getObjects());
90+
return \array_map(static fn($recipient) => $recipient->getName(), $recipientList->getObjects());
9191
}
9292
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,14 @@ public function assignVariables()
6767
),
6868
]);
6969
}
70+
71+
#[\Override]
72+
protected function getContactRecipient(): array
73+
{
74+
return \array_filter(
75+
parent::getContactRecipient(),
76+
fn(int $key) => $key !== $this->formObject->getObjectID(),
77+
\ARRAY_FILTER_USE_KEY
78+
);
79+
}
7080
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function createForm()
7171
->languageItemPattern('wcf.reactionType.title\d+'),
7272
ShowOrderFormField::create()
7373
->required()
74-
->options(new ReactionTypeList()),
74+
->options($this->getReactionTypes()),
7575
BooleanFormField::create('isAssignable')
7676
->label('wcf.acp.reactionType.isAssignable')
7777
->description('wcf.acp.reactionType.isAssignable.description')
@@ -94,4 +94,15 @@ protected function createForm()
9494
$iconContainer,
9595
]);
9696
}
97+
98+
/**
99+
* @return array<int, string>
100+
*/
101+
protected function getReactionTypes(): array
102+
{
103+
$list = new ReactionTypeList();
104+
$list->readObjects();
105+
106+
return \array_map(static fn($option) => $option->getTitle(), $list->getObjects());
107+
}
97108
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,16 @@ public function assignVariables()
5858
),
5959
]);
6060
}
61+
62+
/**
63+
* @return array<int, string>
64+
*/
65+
protected function getReactionTypes(): array
66+
{
67+
return \array_filter(
68+
parent::getReactionTypes(),
69+
fn(int $key) => $key !== $this->formObject->getObjectID(),
70+
\ARRAY_FILTER_USE_KEY
71+
);
72+
}
6173
}

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,7 @@ protected function createForm()
6161
->i18nRequired()
6262
->languageItemPattern('wcf.user.option.category.(category\d+|[\w\.]+)'),
6363
ShowOrderFormField::create()
64-
->options(function () {
65-
$categoryList = new UserOptionCategoryList();
66-
$categoryList->getConditionBuilder()->add('parentCategoryName = ?', ['profile']);
67-
$categoryList->readObjects();
68-
$categories = [];
69-
70-
foreach ($categoryList->getObjects() as $category) {
71-
$categories[$category->categoryID] = $category->getTitle();
72-
}
73-
74-
return $categories;
75-
}),
64+
->options($this->getCategories()),
7665
]),
7766
]);
7867
}
@@ -132,4 +121,19 @@ public function saved()
132121

133122
parent::saved();
134123
}
124+
125+
/**
126+
* @return array<int, string>
127+
*/
128+
protected function getCategories(): array
129+
{
130+
$categoryList = new UserOptionCategoryList();
131+
$categoryList->getConditionBuilder()->add('parentCategoryName = ?', ['profile']);
132+
$categoryList->readObjects();
133+
134+
return \array_map(
135+
static fn($category) => $category->getTitle(),
136+
$categoryList->getObjects()
137+
);
138+
}
135139
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,14 @@ public function saved()
6363

6464
AbstractFormBuilderForm::saved();
6565
}
66+
67+
#[\Override]
68+
protected function getCategories(): array
69+
{
70+
return \array_filter(
71+
parent::getCategories(),
72+
fn(int $key) => $key !== $this->formObject->getObjectID(),
73+
\ARRAY_FILTER_USE_KEY
74+
);
75+
}
6676
}

0 commit comments

Comments
 (0)