Fix MultiSelect when empty selection is given #6768
Merged
+17
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the
BasePicker
and theMultiSelect
widgets try to get the value from the module, if$config['selection']
isempty
(which includes an empty array!).To avoid such a lookup by the widget, one would expect to provide an empty array (which may actually constitute the current selection). However, this will be ignored due to the above.
This PR does treat an empty array as a valid selection list. Thus, avoiding looking up the value.
Additionally, if the field value is an
ArrayAccess
instance, rather than anarray
, the current code fails with a fatal error. UsingArrayHelper::keyExists()
rather thanin_array()
solves this issue.PR Admin
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
If yes, please describe the impact and migration path for existing applications:
Not sure if there are use cases, where and empty array has been provided as
selection
and was expected to be replaced by the attribute value of the model or some other source. To me this would not make sense. Because if you expect theselection
to be filled by the field/widget, then why would you provide an empty array, rather then just leaving the config alone?That's why I currently filed the PR against
master
.The PR fulfills these requirements
develop
branch, not themaster
branch if no hotfixIf adding a new feature, the PR's description includes:
Other information: