Closed hfloyd closed 5 years ago
Hey @hfloyd, what mode are you running ModelsBuilder in? I get a perfectly fine label value when I do @Model.Content.MyColors.Label
so I'm not sure how to reproduce.
Whoop! PR in #4325
Yep, found out that this is exactly the problem, when you click a color for the very first time, it doesn't populate the label value, selecting another color and then the same color "fixes" it. Will review the PR very soon! 👍
Thanks @kjac for the wonderful help today! This has now been fixed and will be available in 7.13.2 due out Tuesday next week. Thanks for reporting @hfloyd !
Thanks @nul800sebastiaan and @kjac for the fast response and detective work! <3
Ps. @nul800sebastiaan - RE: ModelsBuilder Mode: I always use the VS Add-in and compile all models in a separate project from the website.
<add key="Umbraco.ModelsBuilder.Enable" value="true" />
<add key="Umbraco.ModelsBuilder.ModelsMode" value="" />
<add key="Umbraco.ModelsBuilder.EnableApi" value="true" />
<add key="Umbraco.ModelsBuilder.StaticMixinGetters" value="true" />
<add key="Umbraco.ModelsBuilder.LanguageVersion" value="CSharp6" />
Umbraco v.7.13.1
I added a new Color Picker data type, checked to use labels, and filled in several options:
I am using Models Builder, and was pleased to see on my next model generation that the ColorPicker property was converted to a strongly-typed object with two string properties: "Color" and "Label". I would assume that "Color" would return the HEX code (ex: "28593a") and label would return the label (ex: "green")...
But when debugging, I see that both properties are returning JSON strings for the "value" which is the hex code:
Either this is a bug in the PropertyValueConverter code, or I am missing something fundamental...
The code generated by ModelsBuilder:
Eventually I was able to get the result I wanted by stealing some code from the PropertyValueConverter and adding it to a partial for the Model:
But I have a strong feeling that this isn't the most efficient way to handle this...