蛋糕PHP数据不保存到数据库表

时间:2014-03-28 04:59:41

标签: php cakephp

UserController.php

创建的控制器
public function myappointment() {

        $this->loadmodel('event');
        if ($this->request->is('post')) {
           $this->Event->create();

            if ($this->Event->save($this->request->data)) {
                $this->Session->setFlash(__('Your appointment has been saved.'));
            } else {
                $this->Session->setFlash(__('Unable to add your appointment.'));
            }
        }
    }

活动的型号名称 event.php

class Event extends UserMgmtAppModel {


}

视图中的约会表单代码

<?php 
 $this->Form->create('Event');

echo $this->Form->input("title" ,array('label' => false ));

 echo $this->Form->input("from", array('label' =>false, 'type' => 'text', 'class' => 'fl tal vat w300p', 'error' => false , 'id' => 'select_date'));
 echo $this->Html->div('datepicker_img w100p fl pl460p pa', $this->Html->image('calendar.png'),array('id' => 'datepicker_img')); ?>
        <?php echo $this->Html->div('datepicker fl pl460p pa', ' ' ,array('id' => 'datepicker'));
echo 'End time';
 echo $this->Form->input("to", array('label' =>false, 'type' => 'text', 'class' => 'fl tal vat w300p', 'error' => false , 'id' => 'select_date1'));
 echo $this->Html->div('datepicker_img1 w100p fl pl460p pa', $this->Html->image('calendar.png'),array('id' => 'datepicker_img1')); ?>
        <?php echo $this->Html->div('datepicker1 fl pl460p pa', ' ' ,array('id' => 'datepicker1'));

echo $this->Form->end('Create appointment');

1 个答案:

答案 0 :(得分:0)

在您的模型中尝试此操作。

App::uses('UserMgmtAppModel', 'Event.Model');

class Event extends UserMgmtAppModel {

}

您的控制器操作

  public function myappointment() {

    $this->loadmodel('Event');
    if ($this->request->is('post')) {
       $this->Event->create();

        if ($this->Event->save($this->request->data)) {
            $this->Session->setFlash(__('Your appointment has been saved.'));
        } else {
            $this->Session->setFlash(__('Unable to add your appointment.'));
        }
    }
}
相关问题