Copied to clipboard

Flag this post as spam?

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


  • vipin 13 posts 83 karma points
    Sep 05, 2023 @ 10:32
    vipin
    0

    need to restrict past dates in property on umbraco 10

    is it possible to restrict past date in content page by using umbraco 10 date picker?

    Currently, I am working on an Umbraco project, and in this project, the content editor is not allowed to set past dates for the property.

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Sep 10, 2023 @ 09:28
    Marc Goodson
    0

    Hi vipin

    The Umbraco Data Picker is a wrapper around the javascript data picking plugin called flatpickr.js

    This plugin does have the concept of minDate and maxDate from which to pick:

    https://flatpickr.js.org/options/

    It has the option of setting 'minDate' to "today" - to force future dates to be picked:

    https://flatpickr.js.org/examples/#mindate-and-maxdate

    The directive in Umbraco umb-date-time-picker

    https://github.com/umbraco/Umbraco-CMS/blob/6d4809132815b41a6e048904d0769c042abde1cc/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdatetimepicker.directive.js#L96

    seem to pass in configuration options set on the ViewModel in the angularJS controller directly into the flatpickr plugin.

    But there appears to be no UI on the DataType in the backoffice for specifying the various options...

    ... so what you could do is create your own Custom Property Editor that was a wrapper around the umb-date-time-picker directive, but which set the configuration you desired, and call it something like the Future Date Picker...

    You are not having to really do much custom implementation( https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-property-editor) you are just creating your own housing around the existing implementation to set the config you need on flatpickr

    regards

    marc

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies