more control over settings
| Project: | Date |
| Version: | 6.x-2.2 |
| Component: | Date Popup |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Jump to:
When adding date popups to forms in custom modules I would like to be able to have more control over some of the underlying jquery datepicker settings. In particular I would like to disable the month and year dropdowns so the user needs to click forwards and back through the months and I would like to be able to specify the minimum date - so the user can't select a date in the past. I know I can check for the latter in the form validation, but it would be nice if past dates were removed from the picker interface.
Currently I can see that I can override these settings by editing date_popup.module and adding these lines to the end of the $settings array.
'changeMonth' => false,
'changeYear' => false,
'minDate' => 0,But I'd much prefer to be able to control these settings from my custom module when I'm defining the form element. E.g. something like this:
$form['delivery_date'] = array(
'#date_label_position' => 'within',
'#type' => 'date_popup',
'#date_format' => $display_date_format,
'#default_value' => $default_date,
'#date_timezone' => date_default_timezone_name(),
'#date_year_range' => '-0:+1',
'#size' => 15,
'#settings' => array(
'changeMonth' => false,
'changeYear' => false,
'minDate' => 0,
),
);As I wrote this post I realised that it wouldn't be too hard to implement. So I'm attaching a patch for the date_popup.module that should do it. This will allow any of the jquery datepicker settings to be configured from the form element definition, exactly as my example above.
- Drasgard.
| Attachment | Size |
|---|---|
| overrideSettingsArray.patch | 1.1 KB |

#1
#2
You are THE man.
This patch works like a charm.
Hope to see this ASAP on a new version.
#3
#4
I think in some cases it would be better to make the jQuery settings "first class citizens". I personally would like to supply maxdate and mindate. It would work perfectly with the suggested patch, but if it would be made available by using '#maxdate' and '#mindate' (or something similar), the validator function would also be able to enforce these settings. In addition to that, I also would like to disable certain specific dates using the beforeShowDay callback. For this, also support in the validator function would be useful. For other settings, such as the animation settings, it is not necessary to have them as separate # keys in the element definition and this patch would work great there.
#5
I have created a patch that adds the functionality I mentioned. Because more issues request this, I've created a separate issue at #625264: Improvements to date_popup module. I would be very happy if you could take a look at it.
#6
+1 for this feature integrated. Perhaps not this patch as I have no tried it, but I need the ability to add the jquery UI features when I edit the content type's field.
Also it would be nice to provide a hook in date_popup_process_date so we can overwrite the settings in code as well.
<?phpmodule_invoke_all('date_popup_settings', $settings, $element);
?>
--
Drupal & Ubercart Themes