[英]cake PHP data not save to database table
为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');
在您的模型中尝试一下。
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.'));
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.