0

I have a list of Embedded Schema objects that I want to be able to reorder, add, and remove in the list in XPM.

I cannot find any examples of the correct DxaPropertyMarkup to be able to do this.

@if (item.calltoaction.Count > 0)
{
    <ul class="unstyled">
        @foreach (EmbeddedCallToAction calltoaction in item.calltoaction)
        {

            <li @Html.DxaPropertyMarkup(() => item.calltoaction)>
                <a class="@htmlClasses" href="@link" target="@target" title="@title" @Html.DxaPropertyMarkup(() => calltoaction.externallink)>
                    <span @Html.DxaPropertyMarkup(() => calltoaction.label)>@label</span>

                </a>
            </li>
        }
    </ul>
}
2

To get the add, remove, reorder functionality for multivalue properties, you must use the DxaPropertyMarkup method with an index. For multivalue "embedded properties", this should wrap all individual property markups.

@Html.DxaPropertyMarkup(() => Model.MultiValueProperty, index)

In your example, the following line needs to be modified:

<li @Html.DxaPropertyMarkup(() => item.calltoaction)>

As a reference, there is an example in the Core module here (line 15).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.