Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'd like to be able to restrict selectable dates within the datepicker popup. Specifically I'd like to disallow selecting weekend days.
This is how datepicker does this:
http://stackoverflow.com/questions/501943/can-the-jquery-ui-datepicker-b...
I think I can write a PATCH so date module supports this. I'll try first to make it only an option to disallow weekend day selection. I think the function to start writing this is date_popup_process_date, and also modify the widget form right?
I don't know if a more general option can be implemented.
Anyone thinks this might be useful?
Comments
Comment #1
frixos12 CreditAttribution: frixos12 commentedAny progress with this patch?
Comment #2
frixos12 CreditAttribution: frixos12 commentedAs i saw to various jquery examples..
i tried to put this command $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }) in the date_popup.js file (i guess)
using this format but nothing happens
switch (datePopup.func) {
case 'datepicker':
$(this)
.datepicker(datePopup.settings)
.addClass('date-popup-init')
$(this)
.datepicker({ beforeShowDay: $.datepicker.noWeekends })
.addClass('date-popup-init')
I am not familiar with JQuery at all so i need to know if my approach is at least right.
thank you
Comment #3
mlyno CreditAttribution: mlyno commentedI find to control which dates can be (or more can't be) selected are very usefuul and important. Something was tried on D6 #625264: Improvements to date_popup module
Comment #4
KarenS CreditAttribution: KarenS commentedDuplicate of #1143680: Add selector to date_popup element to allow additional options to be passed to jQuery datepicker
Comment #4.0
KarenS CreditAttribution: KarenS commentedspecify possible start point for patch
Comment #5
vjsutar CreditAttribution: vjsutar commentedBy Using jQuery for drupal textfield.
Just create textbox field from drupal backend. Then in js file paste the following code.
Comment #6
mhentry CreditAttribution: mhentry commentedThank you
Comment #7
mhentry CreditAttribution: mhentry commentedComment #8
solideogloria CreditAttribution: solideogloria commentedThis issue should be reopened. Yes, there are other ways to do it with custom jQuery, but the whole point of allowing properties to be passed to the widget is to pass them and have them work. Passing functions to the widget with the intended method does not work at the moment, because they have to be passed as strings.
An easy fix would be to use this patch: https://www.drupal.org/files/issues/date-allow_to_use_beforeShowDay-1143680-23.patch, except that I added the lines inside the select after line 10 of date_popup.js. (This fixes the beforeShowDay property by allowing the stringified function to be evaluated).
Please update the module so that it works for all of the properties out of the box. Thanks.