Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cakephp-使用编辑操作时不填充datepicker引导_Php_Cakephp_Edit - Fatal编程技术网

cakephp-使用编辑操作时不填充datepicker引导

cakephp-使用编辑操作时不填充datepicker引导,php,cakephp,edit,Php,Cakephp,Edit,我在我的应用程序中使用了一个用于引导的日期选择器。以下是我的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"

我在我的应用程序中使用了一个用于引导的日期选择器。以下是我的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> 
控制器

 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格式?这可能是解决方案,或者您检测到 臭虫

编辑:查看


你能从你的控制器动作中显示PHP吗?你真的想要你的输入数据注册为“只读”吗?是的,我真的想要“只读”。。。为什么?我已经完全更新了没有。。。但是我修改了它,不起作用。数据保存为“yyyy-mm-dd”。请再解释一下你的问题。我不明白。user1232375我无法获取来自$this->Registration->read()(用于编辑记录)的日期值并将其放到我的视图中。请尝试var_dump($this->Registration->read())并将输出发布给我!数组(7){[“注册表”]=>数组(10){[“id”]=>int(23)[“项目”]=>string(5)“10000”[“项目版本”]=>NULL[“客户端”]=>string(5)“10001”[“发行类型”]=>string(1)“0”[“类别”]=>NULL[“节奏”]=>string(8)“01:15:00”[“数据注册表”=>string(10)“2013-05-15””comentario”]=>string(13)“测试成功”[“用户id”=>=>数组(9){[“id”]=>字符串(5)“10000”[“pname”]=>字符串(5)“ISPUP”[“url”]=>空[“lead”]=>字符串(7)“修正”[“说明”]=>字符串(428)”
 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');
    }
}
(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);