Compatibility with Dropdown data type
dnwhte opened this issue ยท 5 comments
Hello,
I know this package isn't being actively developed, but I'm wondering if you could give me some direction on making it work with the built in Dropdown data type?
I am getting this error whenever a dropdown is used.
[InvalidCastException: Unable to cast object of type 'System.String' to type 'System.String[]'.]
Umbraco.Core.PropertyEditors.ValueConverters.FlexibleDropdownPropertyValueConverter.ConvertSourceToObject(PublishedPropertyType propertyType, Object source, Boolean preview) +61
Our.Umbraco.Tuple.ValueConverters.TupleValueConverter.ConvertSourceToObject(PublishedPropertyType propertyType, Object source, Boolean preview) +285
Our.Umbraco.PropertyList.ValueConverters.PropertyListValueConverter.ConvertSourceToObject(PublishedPropertyType propertyType, Object source, Boolean preview) +225
Any direction would be much appreciated.
Thanks
Hi @dnwhte!
I've had a quick look at what might be happening here, and it looks that the issue might be this line...
...where it's trying to convert the inner property value (from ConvertDataToSource
) to the ClrType
.
Which in the case of FlexibleDropdownPropertyValueConverter
, that would be a string
...
...but the ConvertDataToSource
method has literally just returned a string[]
...
...so Tuple code doesn't cast/convert it to the correct type, so when the subsequent ConvertSourceToObject
calls are made, it's the wrong type.
That's my (educated) guess at least - I haven't tested this out.
Are you building/running Tuple from source? Would you be willing to try out modifying these lines?
It'd be to ignore the TryConvertTo
bit and set the itemSource
value directly.
e.g.
item.Value = itemSource;
๐ it works!
@dnwhte Cool. (phew!) I'll close off this ticket. Feel free to send over a PR whenever you have time. ๐
Will submit a PR.
Because I don't fully understand how this is working, is this a reliable solution or just a band-aid?
It's reliable, previously it was a bug. That method should return the "source" values, not the end target "object types".