0

In Sitecore 9.2 MVC, we're looking to create a friendly experience for content editors using the Experience Editor for a Date field, but are having issues where the style requirements are that the day and the month have dedicated styles. In order to facilitate these styles, we need to wrap them in html in order to target them for styling.

Currently, we have this:

<div class="event-date-day">
    @Html.Sitecore().Field("Event Start Date", new
    {
      format = "dd",
      EnclosingTag = "span",

    })
</div>
<div class="vent-date-month">
    @Html.Sitecore().Field("Event Start Date", new
    {
      format = "MMM",
      EnclosingTag = "span"
    })
</div>

This works from a presentation standpoint, but in the Experience Editor, trouble is that the field is now selectable/editable in two places in the Experience Editor, and changing the value of either before saving (but after using the date picker UI) does not visually update the other field, causing a visual discrepancy where the editor thinks they need update both places.

Is there a better way to approach this that allows us to only have to use the HtmlHelper once? Perhaps something using "BeginField/EndField"? We're scoured the internet for documentation on the attributes available to pass into these Field HtmlHelper classes, but it has proven extremely difficult to find even an ounce of information that describes in detail any of the attributes, including but not limited to "format" and "haschildren"

Your Answer

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

Browse other questions tagged or ask your own question.