|
23 | 23 | use wcf\system\form\builder\data\processor\CustomFormDataProcessor; |
24 | 24 | use wcf\system\form\builder\field\acl\AclFormField; |
25 | 25 | use wcf\system\form\builder\field\BooleanFormField; |
| 26 | +use wcf\system\form\builder\field\IntegerFormField; |
26 | 27 | use wcf\system\form\builder\field\MultilineTextFormField; |
27 | 28 | use wcf\system\form\builder\field\SelectFormField; |
28 | 29 | use wcf\system\form\builder\field\ShowOrderFormField; |
@@ -243,6 +244,23 @@ protected function getPositionFormFields(): array |
243 | 244 | $categoryNodeTree->setMaxDepth($maximumNestingLevel - 1); |
244 | 245 | } |
245 | 246 |
|
| 247 | + $positionFormField = null; |
| 248 | + if ($maximumNestingLevel === 0) { |
| 249 | + $positionFormField = ShowOrderFormField::create() |
| 250 | + ->description($processor->getLanguageVariable('showOrder.description', true)) |
| 251 | + ->options($categoryNodeTree, true) |
| 252 | + ->nullable() |
| 253 | + ->required(); |
| 254 | + } else { |
| 255 | + // Provide a simple integer input instead because we cannot |
| 256 | + // dynamically filter the list of categories in the position field. |
| 257 | + $positionFormField = IntegerFormField::create('showOrder') |
| 258 | + ->label('wcf.form.field.showOrder') |
| 259 | + ->description($processor->getLanguageVariable('showOrder.description', true)) |
| 260 | + ->minimum(0) |
| 261 | + ->required(); |
| 262 | + } |
| 263 | + |
246 | 264 | return [ |
247 | 265 | SelectFormField::create('parentCategoryID') |
248 | 266 | ->label($processor->getLanguageVariable('parentCategoryID')) |
@@ -336,11 +354,7 @@ static function (SelectFormField $formField) use ($processor) { |
336 | 354 | } |
337 | 355 | ) |
338 | 356 | ), |
339 | | - ShowOrderFormField::create() |
340 | | - ->description($processor->getLanguageVariable('showOrder.description', true)) |
341 | | - ->options($categoryNodeTree, true) |
342 | | - ->nullable() |
343 | | - ->required(), |
| 357 | + $positionFormField, |
344 | 358 | ]; |
345 | 359 | } |
346 | 360 |
|
|
0 commit comments