Posted by i32orgrr on March 6, 2013 at 3:28pm
3 followers
Jump to:
| Project: | Date |
| Version: | 7.x-2.6 |
| Component: | Date Popup |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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:
<?php
$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):
<?php
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
#1
#2
Automatically closed -- issue fixed for 2 weeks with no activity.
#3
Checkout 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.