Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.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
Javascript JQuery日期选择器不';不保存所选日期_Javascript_Php_Jquery_Cakephp_Calendar - Fatal编程技术网

Javascript JQuery日期选择器不';不保存所选日期

Javascript JQuery日期选择器不';不保存所选日期,javascript,php,jquery,cakephp,calendar,Javascript,Php,Jquery,Cakephp,Calendar,我在本地主机和服务器上有一个cakephp3.6项目。我正在使用此日期选择器: <?php echo $this->Form->control('created', ['type' => 'text', 'label' => 'Start date']); ?> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js" ></

我在本地主机和服务器上有一个
cakephp3.6
项目。我正在使用此日期选择器:

<?php
    echo $this->Form->control('created', ['type' => 'text', 'label' => 'Start date']);
?>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js" ></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
  $( function() {
    $( "#created" ).datepicker({ "dateFormat": "dd-mm-yy"});
  } );
  </script>
CustomerServiceTypesController.php

public function add($customerid = null)
    {
        $customerServiceType = $this->CustomerServiceTypes->newEntity();
        if ($this->request->is('post')) {
            $customerServiceType = $this->CustomerServiceTypes->patchEntity($customerServiceType, $this->request->getData());
            if ($this->CustomerServiceTypes->save($customerServiceType)) {

                //debug($this->request->getData("customer_id"),true);
                //if field paid is not null then create a credit transaction
                if(!is_null($this->request->getData("paid")))
                {
                    $customerServiceType_paid = $this->CustomerServiceTypes->newEntity();
                    $customerServiceType_paid->customer_id = $customerid;
                    $customerServiceType_paid->service_type_id = 3; //HARDCODED 
                    $customerServiceType_paid->price = $this->request->getData("paid");
                    $customerServiceType_paid->created = date("Y-m-d H:i:s");
                    $customerServiceType_paid->card = $this->request->getData("card");
                    if ($this->CustomerServiceTypes->save($customerServiceType_paid)) {
                        $this->Flash->success(__('Success'));
                    }
                    else{
                        $this->Flash->error(__('Fail'));
                    }
                }

                $this->Flash->success(__('Success'));

                return $this->redirect(['controller' => 'customers', 'action' => 'edit', $customerid]);
            }
            $this->Flash->error(__('Fail'));
        }
        $customers = $this->CustomerServiceTypes->Customers->find('list', ['limit' => 200])->where(['Customers.id =' => $customerid]);
        $serviceTypes = $this->CustomerServiceTypes->ServiceTypes->find('list', ['limit' => 200]);
        $servicePrices = $this->CustomerServiceTypes
            ->ServiceTypes
            ->find()
            ->limit(200)
            ->combine('id','price');

        $this->set(compact('customerServiceType', 'customers', 'serviceTypes','servicePrices'));
    }

请求开始日期的数据

$this->loadModel('User');
$user=$this->User->get($id);

 $startDate = str_replace('/', '-', $this->request->data['start_date']);

 $user->start_date $startDate->format('Y-m-d H:i:s');

$this->User->save($user);

实际保存信息的PHP脚本在哪里?您的JavaScript似乎没有问题,但我敢打赌查询有问题。您能以html代码(表单)的形式显示吗?可能,无论如何,请注意。
$this->loadModel('User');
$user=$this->User->get($id);

 $startDate = str_replace('/', '-', $this->request->data['start_date']);

 $user->start_date $startDate->format('Y-m-d H:i:s');

$this->User->save($user);