mirror of
https://github.com/humhub/humhub.git
synced 2025-04-21 15:41:54 +02:00
Fix MultiSelect when empty selection is given
This commit is contained in:
parent
e1069cac6c
commit
8f965a2844
@ -1,7 +1,11 @@
|
||||
HumHub Changelog
|
||||
================
|
||||
|
||||
1.15.2 (December 19, 2023)
|
||||
1.15.3 (unreleased)
|
||||
--------------------------
|
||||
- Fix #6768 MultiSelect when empty selection is given
|
||||
|
||||
- 1.15.2 (December 19, 2023)
|
||||
--------------------------
|
||||
- Fix #6753: Non-unique key used for permission caching
|
||||
- Fix #6741: Fix no pretty url of password recovery link
|
||||
|
@ -4,6 +4,12 @@ Module Migration Guide
|
||||
See [humhub/documentation::docs/develop/modules-migrate.md](https://github.com/humhub/documentation/blob/master/docs/develop/modules-migrate.md)
|
||||
for full version.
|
||||
|
||||
Version 1.15.3
|
||||
-------------------------
|
||||
|
||||
### Bugfix with potential side-effect
|
||||
- `\humhub\modules\ui\form\widgets\BasePicker` and `\humhub\modules\ui\form\widgets\MultiSelect` do now treat and empty array for the field `BasePicker::$selection` as a valid selection list and will not attempt to get the list from the model in that case.
|
||||
|
||||
Version 1.15
|
||||
-------------------------
|
||||
|
||||
|
@ -238,7 +238,7 @@ abstract class BasePicker extends JsInputWidget
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->selection != null && !is_array($this->selection)) {
|
||||
if ($this->selection !== null && !is_array($this->selection)) {
|
||||
$this->selection = [$this->selection];
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ abstract class BasePicker extends JsInputWidget
|
||||
*/
|
||||
protected function getSelectedOptions()
|
||||
{
|
||||
if (!$this->selection && $this->model != null) {
|
||||
if ($this->selection === null && $this->model !== null) {
|
||||
$attribute = $this->attribute;
|
||||
if (strrpos($attribute, '[') !== false) {
|
||||
$this->selection = $this->loadItems(Html::getAttributeValue($this->model, $attribute));
|
||||
@ -289,7 +289,6 @@ abstract class BasePicker extends JsInputWidget
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$this->selection) {
|
||||
$this->selection = [];
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
namespace humhub\modules\ui\form\widgets;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* Multiselect
|
||||
*
|
||||
@ -51,7 +53,7 @@ class MultiSelect extends BasePicker
|
||||
|
||||
protected function getSelectedOptions()
|
||||
{
|
||||
if (empty($this->selection)) {
|
||||
if ($this->selection === null) {
|
||||
$attribute = $this->attribute;
|
||||
$this->selection = ($this->model) ? $this->model->$attribute : [];
|
||||
}
|
||||
@ -66,7 +68,7 @@ class MultiSelect extends BasePicker
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$key] = $this->buildItemOption([$key => $value], in_array($key, $this->selection));
|
||||
$result[$key] = $this->buildItemOption([$key => $value], ArrayHelper::keyExists($key, $this->selection));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user