From dd58e504b721cf26db4228c49bdb57835182faaa Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 17 Aug 2018 15:46:39 +0200 Subject: [PATCH] Add missing third parameter in `ISelectionFormField::options()` See 855dba8af4282581bc76127c211f279e5dff5f71 See #2509 --- .../field/ISelectionFormField.class.php | 4 ++-- .../field/ShowOrderFormField.class.php | 4 ++-- .../field/TSelectionFormField.class.php | 21 ++++++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/ISelectionFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/ISelectionFormField.class.php index 1ac8410126..8b3fe94b7c 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/ISelectionFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/ISelectionFormField.class.php @@ -51,13 +51,13 @@ interface ISelectionFormField { * * @param array|callable|DatabaseObjectList $options selectable options or callable returning the options * @param bool $nestedOptions is `true` if the passed options are nested options - * + * @param bool $labelLanguageItems is `true` if the labels should be treated as language items if possible * @return static this field * * @throws \InvalidArgumentException if given options are no array or callable or otherwise invalid * @throws \UnexpectedValueException if callable does not return an array */ - public function options($options, $nestedOptions = false); + public function options($options, $nestedOptions = false, $labelLanguageItems = true); /** * Returns `true` if the field class supports nested options and `false` otherwise. 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 2e429f9462..f309f204ab 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 @@ -63,8 +63,8 @@ class ShowOrderFormField extends SingleSelectionFormField { * and using the language item `wcf.form.field.showOrder.firstPosition` * as value to mark adding it at the first position. */ - public function options($options, $nestedOptions = false) { - parent::options($options, $nestedOptions); + 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; if ($nestedOptions) { diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php index 2c8dcd898e..df687ee469 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php @@ -102,16 +102,27 @@ trait TSelectionFormField { } /** - * Sets the possible options of this selection and returns this field. + * Sets the possible options of this field and returns this field. * * Note: If PHP considers the key of the first selectable option to be empty * and the this field is nullable, then the save value of that key is `null` * instead of the given empty value. * - * @param array|callable $options selectable options or callable returning the options - * @param bool $nestedOptions is `true` if the passed options are nested options - * @param bool $labelLanguageItems is `true` if the labels should be treated as language items if possible - * @return static this field + * If a `callable` is passed, it is expected that it either returns an array + * or a `DatabaseObjectList` object. + * + * If a `DatabaseObjectList` object is passed and `$options->objectIDs === null`, + * `$options->readObjects()` is called so that the `readObjects()` does not have + * to be called by the API user. + * + * If nested options are passed, the given options must be a array or a + * callable returning an array. Each array value must be an array with the + * following entries: `depth`, `label`, and `value`. + * + * @param array|callable|DatabaseObjectList $options selectable options or callable returning the options + * @param bool $nestedOptions is `true` if the passed options are nested options + * @param bool $labelLanguageItems is `true` if the labels should be treated as language items if possible + * @return static this field * * @throws \InvalidArgumentException if given options are no array or callable or otherwise invalid * @throws \UnexpectedValueException if callable does not return an array -- 2.20.1