OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

#8640: Fixing consistency between different Enumeration Field flavors' data storage #8789

Closed BenedekFarkas closed 7 months ago

BenedekFarkas commented 7 months ago

Fixes #8460

Initial logic taken from https://github.com/OrchardCMS/Orchard/issues/8460#issuecomment-784337514. This PR supersedes #8298 and targets 1.10.x instead, because the changes are backwards-compatible.

Tested with a custom content type that has each of the Enumeration Field flavors and saved the same values before/after the change:

Before without anything selected (dropdown defaults to first item)

<EnumerationCheckbox>;;</EnumerationCheckbox>
<EnumerationDropdown>qwer</EnumerationDropdown>
<EnumerationListbox>;;</EnumerationListbox>

After without anything selected (dropdown defaults to first item)

<EnumerationCheckbox></EnumerationCheckbox>
<EnumerationDropdown>;qwer;</EnumerationDropdown>
<EnumerationListbox></EnumerationListbox>

Before with some values selected

<EnumerationCheckbox>;;qwer;asdf;</EnumerationCheckbox>
<EnumerationDropdown>asdf</EnumerationDropdown>
<EnumerationListbox>;;qwer;asdf;</EnumerationListbox>
<EnumerationRadio>yxcv</EnumerationRadio>

After with some values selected

<EnumerationCheckbox>;qwer;asdf;</EnumerationCheckbox>
<EnumerationDropdown>;asdf;</EnumerationDropdown>
<EnumerationListbox>;qwer;asdf;</EnumerationListbox>
<EnumerationRadio>;yxcv;</EnumerationRadio>

Also fixed the issues in 5e48b76278f333f57d5e06458bcb0c7c6bcb865b Sébastien pointed out in https://github.com/OrchardCMS/Orchard/pull/8298#issuecomment-562302112.