hofff / contao-calendarfield

GNU Lesser General Public License v3.0
18 stars 3 forks source link

Dependency between the calendars #27

Closed jankout closed 8 years ago

jankout commented 8 years ago

Hello,

I would wonder to have the possibility to set dependency between 2 calendars. That means that the second calendar should enable only dates after the chosen date in the first calendar. There was an extension with this feature - https://contao.org/de/erweiterungsliste/view/xdependentcalendarfields.10030006.de.html Maybe you can implement something from it? That would be great. Thank you.

aschempp commented 8 years ago

We currently do not have any plans to add such functionality. The whole module is still based on the MooTools version of the date picker supplied in Contao. Most frontends use jQuery today, so it does not make much sense to add features.

Feel free to implement something on your own, would be great if you would contribute it back! https://www.terminal42.ch/en/open-source.html

jankout commented 8 years ago

I would suggest to use jQuery instead of MooTools. There is a quite simple code for the describe case.

e.g.

<script>
  $(function() {
    $('#from').datepicker({
    showOn: "button",
      button:'',
      buttonImageOnly: false,
      buttonText: '<i class="fa fa-calendar"></i>',
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 1,
      dateFormat: "dd.mm.yy",
      showAnim: 'fadeIn',
      gotoCurrent:'true',
      minDate:"+1",
      onClose: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).datepicker({
    showOn: "button",
      button:'',
      buttonImageOnly: false,
      buttonText: '<i class="fa fa-calendar"></i>',
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 1,
      dateFormat: "dd.mm.yy",
      showAnim: 'fadeIn',
      onClose: function( selectedDate ) {
        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
  });
 </script>

More you can find: http://jqueryui.com/datepicker/#date-range