AI OnAI Off
Create a class called TimeEditorDescriptor.cs
[EditorDescriptorRegistration(TargetType = typeof(DateTime?), UIHint = "TimeOnly")]
public class TimeEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
ClientEditingClass = "dijit/form/TimeTextBox";
base.ModifyMetadata(metadata, attributes);
}
}
Use this hint on properties such as the following
[Display(
GroupName = SystemTabNames.Content,
Order = 2,
Name = "Time")]
[UIHint("TimeOnly")]
public virtual DateTime? StartDate { get; set; }
It resolved my issue. Thanks, Scott Reed for the quick response. It's working as expected.
I have the other question on displaying time, How to display the time format like HH:MM instead of hh:mm tt ? What kind of Attribute or Property need to be set in code?
MM is month? If you want 24 hour and minutes that's HH:mm
Try changing TimeEditorDescriptor to
[EditorDescriptorRegistration(TargetType = typeof(DateTime?), UIHint = "TimeOnly")]
public class TimeEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
ClientEditingClass = "dijit/form/TimeTextBox";
EditorConfiguration["constraints"] = new Dictionary<string, string>
{
{ "timePattern", "HH:mm" }
};
base.ModifyMetadata(metadata, attributes);
}
}
I have a business requirement in one model that has time property but it shows both Date & Time as Calendar in the content editor in CMS12.
I have read the article https://github.com/advanced-cms/time-property to fulfill my requirement. But this package is not compatible with CMS12.
Anyone helps me out, How to achieve like time property in CMS12?
Thanks
Vijay