Closed (fixed)
Project:
Date
Version:
7.x-2.6
Component:
Date Popup
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
6 Mar 2013 at 15:28 UTC
Updated:
31 May 2013 at 14:42 UTC
I'm creating a form in Drupal 7 with the form API. Right now, I try to disable Mondays in the popup calendar. My form:
$form['Fecha']=array(
'#title' => t('Fecha'),
'#type' => 'date_popup',
'#date_format' => 'j F Y',
'#date_year_range'=> '0:+1',
'#datepicker_options' => array('minDate' => 0,'firstDay' => 1,),
'#date_label_position' => 'none',
'#default_value' => date('Y-m-d'),
);
I include a js file in my module "Reservas" (reservas.module):
function reservas_init() {
$path = drupal_get_path('module', 'reservas');
// load ui.datepicker from core
drupal_add_library('system', 'ui.datepicker');
// and our js
drupal_add_js($path . '/js/cal_improve.js');
}
and the code in file .js (cal_improve.js):
(function ($) {
Drupal.behaviors.cal_improve = {
attach: function (context) {
for (var id in Drupal.settings.datePopup) {
Drupal.settings.datePopup[id].settings.beforeShowDay =$('#onlyMondays').datepicker({beforeShowDay:onlyMondays});
}
}
}
onlyMondays: function(date){
return [(date.getDay() == 1), ""];
}
})(jQuery);The calendar popup appear but mondays are enables. Any idea?. Thank you in advance!
Comments
Comment #1
i32orgrr commentedComment #3
jonhattanCheckout Work Calendar module http://drupal.org/project/work_calendar. it provides an easy way to do what you want for date fields with no need to code. If you prefer coding, just create a work calendar and add a #work_calendar key to your date_popup form element.
Comment #4
xbrianx commentedAnyway to customize the popup so days can't be click-able if a node is not attached to it? I am going to look into that work calender though some more, but I didn't see anything about nodes and availability there.