6

So I've wanted to change the default format of the date time field in the experience editor. I've had a look and most people suggest

@Editable(item,  x => x.Start_Date, x=>x.Start_Date.ToString("MMMM dd,yyyy"))

but the problem is that, it will only show the custom datetime format on the final page, but I want the custom format to be shown on the experience editor as well.

Is there anyway I can achieve this?

Thanks.

0

2 Answers 2

3

As far as I know this is not possible out of the box, but you can do the following as a workaround:

@using (Html.Glass().BeginEditFrame(Model, "Edit Date", x => x.Start_Date))
{
    Model.Start_Date.ToString("MMMM dd,yyyy")
}

Others maybe have a better solution.

3

When text is rendered in the Experience Editor Glass passes back control for rendering to the Sitecore RenderField pipeline. This has to be done so that Sitecore can render the HTML required to make the field editable.

You will need to add a processor to the RenderField pipeline to handle this scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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