I'm using SXA 1.8 with Sitecore 9.1
For a cloned rendering - in my cshtml I need to conditionally wrap a list item in a link. I have got the link part working, but I can't seem to add title and aria-label attributes?
This is what I've tried in my code:
@Html.Sitecore().BeginField("Link", item, new { haschildren=true, title=item.Fields["DescriptionLinkTitle"], @aria_label = item.Fields["DescriptionLinkTitle"] })
I'm trying not to resort to having something like
<a href="@url" title="@titlefield" aria-label="@titlefield">
stuff
</a>
have also tried @title
.
Note: The haschildren is just because I don't want the text of the link displayed.
The source output is just
<a href="/">
stuff
</a>
So it seems to be ignoring the other attributes I'm trying to add.
item["DescriptionLinkTitle"]
, .Value will throw an exception if the field is empty (you'll need to add a null check) whereas this will just return an empty string