当使用编辑操作时,cakeedatepicker引导不填充


cakedatepicker bootstrap not populate when use a edit action

我在我的应用程序中使用日期拾取器进行引导。下面是我的HTML代码:

<div class="input-append date pull-right" id="dp3" data-date-format="dd-mm-yyyy">
   <input name="dataregisto" id="dataregisto" class="span2" size="16" type="text" readonly>
   <span class="add-on"><i class="icon-th"></i></span>
</div> 

所以当我保存数据时,它正常工作,但当我编辑记录时,日期不显示。另一方面,填充所有剩余的数据。JavaScript代码:

(function($) {
    $(document).ready(function() {
        var today = new Date();
        var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
        $("#dp3").datepicker()
                .on('show', function(ev) {
            $('#dp3').data({date: t}).datepicker('update');
        });
         //    $('#timepicker1').timepicker();

        document.getElementById("dataregisto").value = document.getElementById("dataregisto").defaultValue = t;
    });
})(jQuery);
控制器

 function edit($id = null) {
    session_start();
    if (isset($_SESSION['username'])) { /* verifica se existe uma sessão */
        $this->Registo->id = $id;
        if (empty($this->data)) {
            /* acede aos projetos */
            $this->set('projects', $this->Registo->Project->find('list', array('fields' => array('pname'))));
            /* acede ás versoes do projecto a editar */
            $this->set('projectversions', $this->requestAction("/ProjectVersions/getversionsofproject", array('projects' => $this->Registo->read()['Registo']['projects'])));
            /* acede aos clientes */
            $this->set('clients', $this->requestAction("/CustomFieldOptions/getClients"));
            /* acede ás issuetypes */
            // $issuetype= $this->requestAction("/Projects/getissuetypeofproject", array('projects' => $this->Registo->read()['Registo']['projects']));
            $this->set('dataregisto', $this->Registo->read()['Registo']['dataregisto']);
            /*  $issuetype = array();
              foreach($IssueTypes as $value) {
              $value = $value['IssueType']['id'];
              $issuetype[$value['IssueType']['id']] = $value['IssueType']['pname'];
              }

              debug($issuetype); */
            $this->set('issuetype', $issuetype);
            $this->request->data = $this->Registo->read();
        } else {
            if ($this->Registo->save($this->request->data)) {
                $this->Session->setFlash(__('Registo alterado com sucesso', true), 'flash_success');
                $this->redirect(array('action' => 'index'));
            } else {
                $errors = $this->Registo->invalidFields();
                $this->Messages->customize_error_msg($errors['issuetype']);
            }
        }
    } else {
        $this->redirect(array('controller' => 'users', 'action' => 'login'));
        // $this->Session->setFlash(__('Por favor efetue LOGIN para poder aceder a esta página!', true), 'flash_success');
    }
}

谢谢!

你确定,你保存你插入的数据,例如。在MySQL数据库中dd-mm-yyyy格式?这可能是解或者你检测到abug。

编辑:看一下文档

(function($) {
    $(document).ready(function() {
        var today = new Date(),
t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
        $("#dp3").datepicker().on('show', function(e) {
            e.preventDefault();
            $(this).datepicker('setValue', t);
        });
        document.getElementById("dataregisto").value = document.getElementById("dataregisto").defaultValue = t;
    });
})(jQuery);