sitecoresitecore7glass-mappersitecore7.5

In Sitecore, how does the Glass Mapper Editable feature work when iterating through a collection of objects?


I am using Glass Mapper v3.2.3 with Sitecore v7.5. I see in this tutorial how easy it is to handle a field like a MultiList and get back a list of objects that I can iterate through on my sublayout like this:

<ul class="thumbnails">
    <% foreach (var news in Model.News)
       { %>
    <li class="span3">
        <div class="thumbnail">
            <img src="<%=news.FeaturedImage.Src  %>" alt="<%=news.FeaturedImage.Alt %>">
            <h4>
                <a href="<%=news.Url %>">
                    <%=news.Title %>
                </a>
            </h4>
            <p><%=news.Abstract %></p>
        </div>
    </li>

    <% } %>
</ul>

And I also see how easy it is to make use of the Editable feature in Glass in this tutorial. But what I can't figure out how to do is make the fields editable in the above code when I am iterating through a list of objects. The Editable feature seems to only apply to the underlying Model.

In the above code I want to make the news Feature Image, Title and Abstract all edtiable. Is that even possible using Glass Mapper?


Solution

  • Like so: @Editable(news, x=>x.Title)