I've tried to create a second DatePicker, but one that also allows for Time to be selected.
My FieldType.DateTimePicker is
@model Umbraco.Forms.Mvc.Models.FieldViewModel
@{
string val = string.Empty;
if (Model.ValueAsObject != null && Model.ValueAsObject != "")
{
DateTime d;
d = (DateTime)Model.ValueAsObject;
val = d.ToShortDateString();
}
}
<input type="text" name="@Model.Name" id="@Model.Id" class="datepickerfield" value="@val"
@{if (Model.Mandatory)
{
<text> data-val="true" data-val-required="@Model.RequiredErrorMessage" </text>
}}
/>
The file is placed under Partials/Forms/Fieldtypes.
I also have a DateTimePicker.cs class
namespace FALCO_CLIENT.App_Plugins.UmbracoForms
{
public class DateTimePicker : Umbraco.Forms.Core.FieldType
{
[Umbraco.Forms.Core.Attributes.Setting("ValueAsObject", description = "DateTimePicker", view = "DateTimePicker")]
public DateTime ValueAsObject { get; set; }
public DateTimePicker() {
//Provider
this.Id = new Guid("D6A2C406-CF89-11DE-B075-66B155D89593 ");
this.Name = "DateTimePicker";
this.Description = "Renders a html input";
this.Icon = "icon-autofill";
this.DataType = FieldDataType.DateTime;
this.SortOrder = 10;
}
}
}
and I have a small View (DateTimePicker.html) for the class:
<input tabindex="-1" type="text" /> <button class="btn"><i class="icon icon-calendar"></i></button>
In Umbraco Forms I do get the option to "pick" DateTimePicker, but it only generates a Text-field which I can write in.
What am I doing wrong?
As a follow up question: Where do I set the DatePicker to allow time? I was thinking that I would do it in the umbraco.forms.js, but I can't find the correct place.