From: Matthias Schmidt Date: Sun, 12 May 2019 09:44:14 +0000 (+0200) Subject: Fix double `(first position)` when using callable for show order field options X-Git-Tag: 5.2.0_Alpha_1~96 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e71b751e96a0c091e19f25e048dacb0e2a504262;p=GitHub%2FWoltLab%2FWCF.git Fix double `(first position)` when using callable for show order field options See #2509 --- diff --git a/wcfsetup/install/files/lib/system/form/builder/field/ShowOrderFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/ShowOrderFormField.class.php index 77fe58392b..1bf964eeb9 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/ShowOrderFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/ShowOrderFormField.class.php @@ -31,6 +31,12 @@ use wcf\system\WCF; class ShowOrderFormField extends SingleSelectionFormField { use TDefaultIdFormField; + /** + * is `true` if `(first position)` option was added + * @var bool + */ + protected $addedFirstPositionOption = false; + /** * Creates a new instance of `ShowOrderFormField`. */ @@ -66,12 +72,16 @@ class ShowOrderFormField extends SingleSelectionFormField { public function options($options, $nestedOptions = false, $labelLanguageItems = true) { parent::options($options, $nestedOptions, $labelLanguageItems); - $this->options = [0 => WCF::getLanguage()->get('wcf.form.field.showOrder.firstPosition')] + $this->options; - array_unshift($this->nestedOptions, [ - 'depth' => 0, - 'label' => WCF::getLanguage()->get('wcf.form.field.showOrder.firstPosition'), - 'value' => 0 - ]); + if (!$this->addedFirstPositionOption) { + $this->options = [0 => WCF::getLanguage()->get('wcf.form.field.showOrder.firstPosition')] + $this->options; + array_unshift($this->nestedOptions, [ + 'depth' => 0, + 'label' => WCF::getLanguage()->get('wcf.form.field.showOrder.firstPosition'), + 'value' => 0 + ]); + + $this->addedFirstPositionOption = true; + } return $this; }