Hello,
Based on Skyler's "Updating an existing entity. How to add a new property" tutorial (and a lot of help from the gentleman himself) I was able to sucessfully add 3 new properties to the PoductVariant entity. The code is working as expected except for one thing... when I edit the properties in the admin view the values I enter get saved to the database as encoded.
In my view (\Presentation\Nop.Web\Administration\Views\Shared\_ProductVariantInfo.cshtml) I coded of my properties to be displayed using the rich editor as follows:
<tr>
<td class="adminTitle">
@Html.NopLabelFor(model => model.myVariant1):
</td>
<td class="adminData">
@Html.EditorFor(x => x.Specs, "RichEditor")
@Html.ValidationMessageFor(model => model.myVariant2)
</td>
</tr[/b]>[/i]
I my model (\Presentation\Nop.Web\Administration\Models\Catalog\ProductVariantModel.cs) I coded the properties as follows:
[NopResourceDisplayName("Admin.Catalog.Products.Variants.Fields.myVariant1")]
[AllowHtml]
public string Specs { get; set; }
[NopResourceDisplayName("Admin.Catalog.Products.Variants.Fields.myVariant2")]
[AllowHtml]
public string Downloads { get; set; }
The view displays fine and I can edit the fields and everything looks and works great until I do a save (or save and continue). At that point the data I entered gets Html encoded before it is stored in the database and displayed back to the screen. Code which should be stored like...
<strong>Size: </strong>10" x 7" with 12" Handle<strong>Unit Weight:</strong> .2 lbs.
ends up looking like...
<strong>Size: </strong>10" x 7" with 12" Handle<strong>Unit Weight:</strong> .2 lbs.
I found the following comment in the RichEditor.cshtml file, and think it may be the answer to my problem, I just can't figure out where to go with it....
@(
Html.Telerik().Editor().Name(clientId)
/*.Encode(false) weird. Settings "Encode(false)" doesn't work on category & product details page
Now we have to manually decode values*/
It looks like I need to manually decode my values once they have been returned, and before they're stored in the DB, but I can't find the place I should be doing it. The only other field I see on the admin product and category details pages that uses the rich editor is FullDescription, but I don't see anything different in the way it's coded as apposed to what I've done.
Can anyone point me in the right direction?
Thanks.
Tim