From 5d37eaf993394cb0d2124594655752c3c6eb5197 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 25 Aug 2014 14:32:35 +0200 Subject: [PATCH] #U4-4673 Fixed Due in version: 7.1.6 --- .../PropertyEditors/FileUploadPropertyEditor.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs index 28da565b9e..2c67920d58 100644 --- a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Drawing; +using System.Globalization; using System.Linq; using System.Text.RegularExpressions; using System.Xml; @@ -149,24 +150,28 @@ namespace Umbraco.Web.PropertyEditors /// public override IDictionary ConvertDbToEditor(IDictionary defaultPreVals, PreValueCollection persistedPreVals) { - var result = new Dictionary(); + var result = new List(); //the pre-values just take up one field with a semi-colon delimiter so we'll just parse var dictionary = persistedPreVals.FormatAsDictionary(); if (dictionary.Any()) { //there should only be one val - var delimited = dictionary.First().Value.Value.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries); + var delimited = dictionary.First().Value.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (var index = 0; index < delimited.Length; index++) { - result.Add(index.ToInvariantString(), delimited[index]); + result.Add(new PreValue(index, delimited[index])); } } //the items list will be a dictionary of it's id -> value we need to use the id for persistence for backwards compatibility - return new Dictionary { { "items", result } }; + return new Dictionary { { "items", result.ToDictionary(x => x.Id, x => PreValueAsDictionary(x)) } }; } + private IDictionary PreValueAsDictionary(PreValue preValue) + { + return new Dictionary { { "value", preValue.Value }, { "sortOrder", preValue.SortOrder } }; + } /// /// Take the posted values and convert them to a semi-colon separated list so that its backwards compatible ///