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 224 posts 555 karma points
    6 days ago
    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 101 posts 427 karma points
    6 days ago
    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 224 posts 555 karma points
    5 days ago
    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 33 posts 79 karma points
    5 days ago
    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 224 posts 555 karma points
    5 days ago
    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 101 posts 427 karma points
    5 days ago
    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 224 posts 555 karma points
    4 days ago
Please Sign in or register to post replies

Write your reply to:

Draft