0

I have a defaultTime setup that takes the device clock and set it as default for the first timepicker, and for the second it just sets +1 hour from the first one. That is how it works when I load it.

But what I want to achieve is pretty similar to google docs calendar. If I change the first timepicker, it should also change the second. If I change the second, that should only create a timedifference between timepicker nr 1 and nr 2. That means if nr 1 is showing 10.00 and nr 2 is showing 11, if I change nr 2 to 12 and then start changing nr 1, it should keep the difference as 2 hours unless I change nr 2 back.

Here is my code for the HTML and PHP

<div class="col-md-6 timeField" <?= !$calendarEntryForm->showTimeFields() ? 'style="opacity:0.2"' : '' ?>>
        <?= $form->field($calendarEntryForm, 'start_time')->widget(TimePicker::class,
        [
            'readonly' => false,
            'pluginOptions' => [
                'minuteStep' => 5,
                'defaultTime' => date('H:00', strtotime('+1 hour')),
            ],
            'options'=>[
                'class'=>'form-control',
            ]
        ],
                ['disabled' => $calendarEntryForm->entry->all_day]); ?>
    </div>
</div>


  <div class="col-md-6 timeField" <?= !$calendarEntryForm->showTimeFields() ? 'style="opacity:0.2"' : '' ?>>
        <?= $form->field($calendarEntryForm, 'end_time')->widget(TimePicker::class,
        [
            'readonly' => false,
            'pluginOptions' => [
                'minuteStep' => 5,
                'defaultTime' => date('H:00', strtotime('+2 hour')),
            ],
            'options'=>[
                'class'=>'form-control',
            ]
        ],
                ['disabled' => $calendarEntryForm->entry->all_day]); ?>
    </div>
</div>

The timepicker which is used is Kartik Visweswaran from Krajee.com.

I assume I need to fix this in the javascript file with jQuery, but I'm not sure how to do it. If some information is missing that makes it hard for you to help, just reply with what you need.

EDIT:

HTML from console

enter image description here

Does anyone knows? Its prob a jQuery thing I need to do and connect it to the divclass without getting an error, so it reacts with the change in the current timepicker

stAMy
  • 471
  • 2
  • 6
  • 14
  • I guess this question will be easier to answer if you provide the pure HTML that is generated by PHP -- so the HTML as it appears in the browser (view source). – trincot Jan 10 '18 at 19:30
  • @trincot Do you mean the HTML from the timepickers? – stAMy Jan 10 '18 at 19:41
  • I mean the HTML as it is rendered. Open the page in a browser, and from the context menu choose "view page source" or something similar. Then post the part that corresponds to the above PHP code snippet, but which will have expanded to plain HTML. – trincot Jan 10 '18 at 19:52
  • I uploaded a screenshot now! Thanks! Wasnt possible to mark and copy paste it, unfortunately @trincot – stAMy Jan 10 '18 at 20:15
  • Please post as text. You can save the source as HTML file on your desktop, open that file in notepad and copy it from there. – trincot Jan 10 '18 at 20:31
  • It doesnt seem to show on there because where I want it to be is in a modal-dialog box. So the HTML for the code I posted doesnt appear in the "view page source" @trincot – stAMy Jan 10 '18 at 20:40
  • Just save the page on your desktop. I don't know the framework you use, so I cannot really help without seeing the plain HTML. Maybe someone else can. – trincot Jan 10 '18 at 20:40
  • I saved it! But what do you want me to do with it? I cant find the spesific html we are looking for, so the file is pretty long to be posted @trincot – stAMy Jan 10 '18 at 20:47
  • You can locate `start_time` in the HTML file and copy from there. Also, do you have JavaScript? I see `data-action-change="adjustTime"`, but where is `adjustTime` defined? – trincot Jan 10 '18 at 20:51
  • That was something I tried and which I removed. So just ignore adjustTime. There is no start_time in the HTML file. Thats kinda the issue @trincot – stAMy Jan 10 '18 at 20:58

0 Answers0