From 3722dc30d6cbb6d3926a5e060849d3bd565128f8 Mon Sep 17 00:00:00 2001 From: Func Date: Wed, 9 Feb 2022 02:36:43 +0000 Subject: [PATCH] HTMLMultiSelectField: Add forced-on options to the output of filter Forced-on options (selected as default but disabled) should always in the loaded data, like what HTMLCheckMatrix do. Change-Id: I342928eca01ae8a9f34ee7156a515524c3a0d9dd --- includes/htmlform/fields/HTMLMultiSelectField.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/htmlform/fields/HTMLMultiSelectField.php b/includes/htmlform/fields/HTMLMultiSelectField.php index e3f8ded7e59..f9720d556be 100644 --- a/includes/htmlform/fields/HTMLMultiSelectField.php +++ b/includes/htmlform/fields/HTMLMultiSelectField.php @@ -292,10 +292,11 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable public function filterDataForSubmit( $data ) { $data = HTMLFormField::forceToStringRecursive( $data ); $options = HTMLFormField::flattenOptions( $this->getOptions() ); + $forcedOn = array_intersect( $this->mParams['disabled-options'], $this->getDefault() ); $res = []; foreach ( $options as $opt ) { - $res["$opt"] = in_array( $opt, $data, true ); + $res["$opt"] = in_array( $opt, $forcedOn, true ) || in_array( $opt, $data, true ); } return $res;