mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Merge branch 'fix/multiselect' of github.com:metaworx/humhub into metaworx-fix/multiselect
This commit is contained in:
commit
dd2d23058d
@ -47,6 +47,8 @@ At least PHP 8.0 is required with this version.
|
||||
- `\humhub\modules\content\models\Content` on `canEdit()`, `canView()`
|
||||
- `\humhub\modules\file\models\File` on `canRead()`, `canDelete()`
|
||||
|
||||
### 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
|
||||
|
@ -239,7 +239,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];
|
||||
}
|
||||
|
||||
@ -281,7 +281,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));
|
||||
@ -290,7 +290,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
|
||||
*
|
||||
@ -50,7 +52,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 : [];
|
||||
}
|
||||
@ -65,7 +67,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