Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Fix rendering select element when value is an object #218

Merged
merged 1 commit into from
Dec 11, 2018
Merged

Fix rendering select element when value is an object #218

merged 1 commit into from
Dec 11, 2018

Conversation

Erikvv
Copy link
Contributor

@Erikvv Erikvv commented Aug 16, 2018

Use a select element with object as values (identifiers). The select element I believe is the only element which exhibits this behavior

The select element works when submitting, but it will not render a selected option as selected.

Select element works the same as using string values, relying on __toString()

@@ -285,7 +285,7 @@ protected function validateMultiValue($value, array $attributes)
}

if (! is_array($value)) {
return (array) $value;
return [$value];
Copy link
Contributor Author

@Erikvv Erikvv Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual fix.

This line worked for string and int, creating an array with 1 element.

But for an object it will make an array of its properties and later on it will be treated like multiple values as if it's a multiselect.

@weierophinney weierophinney added this to the 2.12.1 milestone Dec 11, 2018
@weierophinney weierophinney merged commit cbc3b2f into zendframework:master Dec 11, 2018
weierophinney added a commit that referenced this pull request Dec 11, 2018
@weierophinney
Copy link
Member

Thanks, @Erikvv!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants