Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lori ryan 239 posts 573 karma points
    May 04, 2021 @ 18:03
    lori ryan
    0

    umbraco forms - date picker

    whats the correct way to set the date format? or is there a way to stop people from entering text?

    when I enter 19/3/1970 and the following is displayed: January 1, 1753

  • iNETZO 134 posts 497 karma points c-trib
    May 04, 2021 @ 20:50
    iNETZO
    1

    Hi Lori,

    We've added an readonly="readonly" attribute to ~/Views/Partials/Forms/Themes/default/Fieldtypes/FieldType.DatePicker.cshtml to stop let users enter text.

    <input type="text" name="@Model.Name" id="@(Model.Id)_1" data-umb="@(Model.Id)_1" class="datepickerfield" readonly="readonly" autocomplete="off" value="@val" @{if (Model.Mandatory) { <text> data-val="true" data-val-required="@Model.RequiredErrorMessage" </text> }} />
    

    If you have created an theme yourself you can add this modification to your own theme to make it update-proof for upcomming Forms updates.

    The date format that is applied depends on the culture settings of your site.

    Best regards,

    iNETZO

  • lori ryan 239 posts 573 karma points
    May 05, 2021 @ 10:49
    lori ryan
    0

    Hi iNETZO

    I've added that in - is there any code around say if I wanted a different date picker maybe the bootstrap date picker?

    https://codepen.io/Yuping/pen/xqrjE

  • AnandBhopale 54 posts 172 karma points
    May 05, 2021 @ 11:34
    AnandBhopale
    0

    Hi Lori,

    Where you are planning to add date picker control ? if it is umbraco form, then form has different date picker control and it uses Pikaday JS library.

  • lori ryan 239 posts 573 karma points
    May 05, 2021 @ 12:41
    lori ryan
    0

    Yes going to try adding my own field type - client doesn't like the functionality of the otb datepicker. Says the year dropdown isnt obvious.

    https://our.umbraco.com/documentation/Add-ons/umbracoforms/developer/extending/adding-a-fieldtype

  • iNETZO 134 posts 497 karma points c-trib
    May 05, 2021 @ 13:19
    iNETZO
    1

    Instead of adding your own fieldtype, which is an good option if you want additional settings, you could also change the FieldTypeViewName property to your own view.

    public class DatePicker : Umbraco.Forms.Core.Providers.FieldTypes.DatePicker
    {
        public DatePicker()
        {
            this.FieldTypeViewName = "FieldType.BootStrapDatePicker.cshtml";
        }
    }
    
  • lori ryan 239 posts 573 karma points
    May 06, 2021 @ 13:17
Please Sign in or register to post replies

Write your reply to:

Draft