0

I have events that have a datetime input for the start and end of the event. If I try to save the start 12-8-2015 at 11:30am and the end 12-8-2015 at 12:30pm the event gets save but it makes the date 12-9-2015. I don't know why it is doing this. I have tried adding validation rules like 'datetime', and 'notBlank', but that would just give me errors saying the fields were invalid and/or required. So I took the validation rules out. Any suggestions why the behavior is so weird with datetime?

Form:

<?= $this->Form->create($event, ['type' => 'file']);?>
        <fieldset>
            <legend><?= __('Edit Event'); ?></legend>
        <?php
            echo $this->Form->input('id');
            echo $this->Form->input('event_type_id');
            echo $this->Form->input('event_img', ['type' => 'file']);
            echo $this->Form->input('title');
            echo $this->Form->input('location');
            echo $this->Form->input('details');
            echo $this->Form->input('cost');
            echo $this->Form->label('Start Time');
            echo $this->Form->datetime('start', ['interval' => 15, 'timeFormat' => 12]);
            echo $this->Form->label('End Time');
            echo $this->Form->datetime('end', ['interval' => 15, 'timeFormat' => 12]);
            echo $this->Form->input('all_day');
            echo $this->Form->input('status', ['options' => [
                        'Scheduled' => 'Scheduled','Confirmed' => 'Confirmed','In Progress' => 'In Progress',
                        'Rescheduled' => 'Rescheduled','Completed' => 'Completed'
                        ]
                    ]
                );
        ?>
        </fieldset>
    <?= $this->Form->button(__('Submit', true));?>
    <?= $this->Form->end(); ?>
Battousai
  • 503
  • 7
  • 17
  • Can you add the result of `debug($this->request->data)` to your question please? What type does the database field for "start" and "end" have? – Oops D'oh Dec 22 '15 at 04:05
  • The fields are datetime in the database. Debugging gets me nothing because the event is saved "without" issues. – Battousai Dec 22 '15 at 04:28
  • 12:30PM is the next day – arilia Dec 22 '15 at 08:10
  • Use `12:30AM` instead of `12:30PM`. Or just use 24hr clock and be done with it ;) – ankr Dec 22 '15 at 15:40
  • @ankr Uh what? the event goes from 11:30am to 12:30pm if cake can't handle that don't you think there is a problem? – Battousai Dec 22 '15 at 22:27
  • @arilia 11:30am is the morning. 12:30pm is the afternoon of the same day. – Battousai Dec 22 '15 at 22:28
  • "_Debugging gets me nothing ..._" excusez moi? I'd say it's the exactly the opposite, _not_ debugging gets you nothing. Debugging is the way to go, and the first things to check are what exactly the request data looks like (as mentioned by @OopsD'oh), and when exactly it changes (when creating/patching the entity probably). – ndm Dec 25 '15 at 13:51
  • @ndm what I mean is that my debug log is empty and when I try to debug($this->request->data), I don't get any thing reported back... there isn't anything printed out – Battousai Dec 27 '15 at 06:35
  • Then you probably have disabled the debug mode. http://book.cakephp.org/3.0/en/development/configuration.html#general-configuration – ndm Dec 27 '15 at 14:42

0 Answers0