It would be awesome if the end date gets synchronized with the start date. So, when selecting a start date using the pop-up, you don't have to select the same date again for the end date.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BarisW’s picture

Status: Active » Needs review
FileSize
1.51 KB

Here's a rough patch that adds this functionality.

I now made it configurable in the admin interface by adding an extra option under the date Field Settings > More settings and values > Default values > Default end date.

Status: Needs review » Needs work

The last submitted patch, 1: 2331975-1-sync-end-date-for-date-popup.patch, failed testing.

BarisW’s picture

Status: Needs work » Needs review
FileSize
1.54 KB
674 bytes
julou’s picture

Do you really need to patch a core module for that?
Can't you rely on a js based solution? e.g. http://tylerfrankenstein.com/code/drupal-automatically-set-date-when-dat...

BarisW’s picture

The Date module is not a core module. It's a contrib?

julou’s picture

Sorry… my mistake.

Status: Needs review » Needs work

The last submitted patch, 3: 2331975-3-sync-end-date-for-date-popup.patch, failed testing.

hanness’s picture

StryKaizer’s picture

#3 did not work with multi-value date fields.
I altered the code to also work with multivalue fields.

This patch requires date >= 2.9

StryKaizer’s picture

Status: Needs work » Needs review
eidoscom’s picture

I tried the last patch with multivalue field and now it works :)

Thanks!

eidoscom’s picture

Status: Needs review » Reviewed & tested by the community
hcderaad’s picture

The patch from #10 does indeed work with Date Version: 7.x-2.9, thank you!

Is there any planning about when this could be integrated in the contrib Date module?

Peter Arius’s picture

I appreciate this effort, of course, but found that the Smart Dates module is the more convenient solution: Set a default duration for the date field (which will pre-popuplate end date+time), and then Smart Dates will keep end date/time in synch when user changes the start date/time.

Hope that this patch won't interfere with Smart Dates when it will be committed, or that both approaches can be merged.

podarok’s picture

Status: Reviewed & tested by the community » Fixed

#10 merged. Thanks.

  • podarok committed 02eeea3 on 7.x-2.x authored by StryKaizer
    Issue #2331975 by BarisW, StryKaizer: Sync end date for the date popup...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

echoz’s picture

abdolmaleki’s picture

FileSize
5.19 KB

This feature does not work when I use datex module as a date picker because This feature depends on the date_popup.js file, and when another module is used as a date picker, this file does not load. How to write a separate JavaScript file for this feature to load on the page anyway?
and how do you think I put this code

if (datePopup.settings.syncEndDate) {
            $('.start-date-wrapper').each(function(){
              var start_date_wrapper = this;
              $(this).find('input:eq(0)').change(function(){
                $(start_date_wrapper).next('.end-date-wrapper').find('input:eq(0)').val($(this).val());
              });
            });
          }  

in datex.js file to solve my problem?

DamienMcKenna’s picture

@abdolmaleki: Please open a new issue for this, thank you.