Unplanned
Last Updated: 20 Nov 2023 14:14 by Greg
Greg
Created on: 20 Nov 2023 14:14
Category: Form
Type: Bug Report
2
The Form autogenerated date picker with nullable DateOnly / TimeOnly value shows '1/1/2001' / '12:00 AM' instead of 'M/d/yyyy' / 'h:mm aa' like the standard TelerikDatePicker

My Nullable DateOnly field shows as 1/1/2001 - I would expect it to be a more sensible default. The problem is applicable only for the Form autogenerated DatePicker. The same issue is applicable for the TimeOnly type.

 

===ADMIN EDIT===

In the interim, as a viable workaround, you can utilize the FormItem Template and declare a TelerikDatePicker like this:

@using System.ComponentModel.DataAnnotations

<TelerikForm Model="@PersonModel">
    <FormValidation>
        <DataAnnotationsValidator></DataAnnotationsValidator>
    </FormValidation>
    <FormItems>
        <FormItem>
            <Template>
                <label for="country">Date of Birth:</label>
                <TelerikDatePicker @bind-Value="@PersonModel.DOB" Width="200px" />
            </Template>
        </FormItem>
    </FormItems>
</TelerikForm>

@code {
    private Person PersonModel { get; set; } = new Person() { DOB = null };

    public class Person
    {
        [Display(Name = "Date of Birth")]
        public DateOnly? DOB { get; set; }
    }
}

 

0 comments