Search code examples
c#.netasp.net-corenopcommerce

How to fix linking a nopcommerce rich text editor with index in List of objects?


I am wondering how to fix the nopCommerce nop-edit with rich text editor enabled. Basically in my model I have a property which is a List of custom objects. In the object there is a property Value. And this is the property I want to "link". But I just get a bunch of empty rich text editors and none of them have a value in them. Upon detailed inspection I see that all the text editors have the name and Id set. It is the correct one (at least it should be).

Here is my partial .cshtml file code.

<div class="card-body">
    @if (Model.HasAvailableSpecificationAttributes)
    {
        int counter = 0;

        foreach (var specAttribute in Model.SpecificationAttributes)
        {
            <div class="card card-default">
                <div class="card-body">
                    <h2>@specAttribute.Name</h2>
                    <div class="form-group row">
                        <div class="col-md-2">
                            <nop-label asp-for="@Model.SpecificationAttributes[counter].Value" />
                        </div>
                        <div class="col-md-10">
                            <input asp-for="@Model.SpecificationAttributes[counter].Id" type="hidden" />
                            <nop-editor asp-for="@Model.SpecificationAttributes[counter].Value" asp-template="RichEditor" />
                            <span asp-validation-for="@Model.SpecificationAttributes[counter].Value"></span>
                        </div>
                    </div>
                </div>
            </div>

            counter++;
        }
    }
    else
    {
        <div class="card card-default">
            <div class="card-body">
                @T("Admin.Catalog.Products.SpecificationAttributes.NoAttributes")
            </div>
        </div>
    }

</div>

Also another thing... when I change out the nop-editor tag with the nop-textarea one, it works as expected, but I need a rich text editor.


Solution

  • The answer has been posted as an issue on the nopCommerce repository.

    See: https://github.com/nopSolutions/nopCommerce/issues/6816