Fixed an issue where unchecked checkboxes would remain checked.

The issue was that by combining existing element data with posted element data, the existing items would retain their values in case no such item was posted, which is the case for unchecked checkboxes; their name/value pair will  be not posted, so the original value would be retained.
This is fixed by no longer combining existing data with hosted data, but instead relying that an element editor will post all data that it is concerned with.
This commit is contained in:
Sipke Schoorstra
2015-02-28 15:52:37 +01:00
parent 11ffc90afa
commit 9c2e1f9e56

View File

@@ -104,7 +104,7 @@ namespace Orchard.Layouts.Controllers {
var contentType = sessionState.ContentType;
var describeContext = CreateDescribeContext(contentId, contentType);
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, model.TypeName);
var data = ElementDataHelper.Deserialize(model.ElementData).Combine(Request.Form.ToDictionary());
var data = Request.Form.ToDictionary();
var element = _elementManager.ActivateElement(descriptor, e => e.Data = data);
var context = CreateEditorContext(session, describeContext.Content, element, elementData: data, updater: this);
var editorResult = _elementManager.UpdateEditor(context);
@@ -190,7 +190,7 @@ namespace Orchard.Layouts.Controllers {
var contentType = sessionState.ContentType;
var describeContext = CreateDescribeContext(contentId, contentType);
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, model.TypeName);
var data = ElementDataHelper.Deserialize(model.ElementData).Combine(Request.Form.ToDictionary());
var data = Request.Form.ToDictionary();
var element = _elementManager.ActivateElement(descriptor, e => e.Data = data);
var context = CreateEditorContext(session, describeContext.Content, element, data, updater: this);
var editorResult = _elementManager.UpdateEditor(context);