Jquery Cake PHP 2.x保存表单不起任何作用
我是cakePhP新手,我需要你的帮助 我正在尝试制作一个管理事件的日历。所以我选择了fullcalendar jQuery插件来实现这一点。然后,我按照本教程将日历集成到我的项目中,以便在数据库中存储事件: 我知道它处理的是旧版本的cakePHP,但我一直在继续,直到我分享的部分。我的日历正确显示数据库中存储的事件。但我不能添加事件, 这才是真正的问题。 我在add.ctp视图中使用如下保存表单:`Jquery Cake PHP 2.x保存表单不起任何作用,jquery,forms,cakephp,Jquery,Forms,Cakephp,我是cakePhP新手,我需要你的帮助 我正在尝试制作一个管理事件的日历。所以我选择了fullcalendar jQuery插件来实现这一点。然后,我按照本教程将日历集成到我的项目中,以便在数据库中存储事件: 我知道它处理的是旧版本的cakePHP,但我一直在继续,直到我分享的部分。我的日历正确显示数据库中存储的事件。但我不能添加事件, 这才是真正的问题。 我在add.ctp视图中使用如下保存表单:` <?php echo $this->Form->create(
<?php
echo $this->Form->create("Event",array('action'=>'add'));
echo $this->Form->input('title' , array('label' => 'Nom de l\'absence'));
echo '<br/> Quand : ' . $displayTime;
echo $this->Form->input('allday', array('type'=>'hidden','value'=>$event['Event']['allday']));
echo $this->Form->input('start', array('type'=>'hidden','value'=>$event['Event']['start']));
echo $this->Form->input('end', array('type'=>'hidden','value'=>$event['Event']['end']));
echo $this->Form->end(array('label'=>'Save' ,'name' => 'save'));
?>
<input type="button" value="Retour" onclick="back();">
<script type="text/javascript">
function back() {
window.location.href ="/calendars/display";
}
</script>
以下是控制器中的“添加”:
function add($allday=null,$day=null,$month=null,$year=null,$hour=null,$min=null) {
if($this->request->is('post')) {
//Create and save the new event in the table.
$this->Event->create();
$this->data['Event']['editable']='1';
if($this->Event->save($data)){
$this->Session->setFlash('GG');
}
else {
$this->Session->setFlash('ERROR');
}
}else{
//Set default duration: 1hr and format to a leading zero.
$hourPlus=intval($hour)+1;
if (strlen($hourPlus)==1) {
$hourPlus = '0'.$hourPlus;
}
//Create a time string to display in view.
if ($allday=='true') {
$event['Event']['allday'] = 1;
$displayTime = 'All day event: ('
. date('D',strtotime($day.'/'.$month.'/'.$year)).' '.
$day.' / '. date("M", mktime(0, 0, 0, $month, 10)).')';
} else {
$event['Event']['allday'] = 0;
$displayTime = date('D',strtotime($day.'/'.$month.'/'.$year)).' '
.$day.' / '.date("M", mktime(0, 0, 0, $month, 10)).
', '.$hour.' : '.$min.' — '.$hourPlus.' : '.$min;
}
$this->set("displayTime",$displayTime);
//Populate the event fields for the add form
$event['Event']['title'] = 'Nom de l\'événement';
$event['Event']['start'] = $year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
$event['Event']['end'] = $year.'-'.$month.'-'.$day.' '.$hourPlus.':'.$min.':00';
$this->set('event',$event);
$this->layout="ajax";
}
它进入我的第一个else块,然后向我显示“ERROR”。
我使用了调试器,但似乎没有什么异常。validationErrors()数组为空,
最后完成的查询是一个acos、aros和权限,数组包含好的数据,可以存储,但不想保存
你能帮我吗 我回答我自己的问题:在线 如果($this->Event->save($data)){ 只需将$data替换为$this->data即可 我花了几天时间才摆脱羞耻感
function add($allday=null,$day=null,$month=null,$year=null,$hour=null,$min=null) {
if($this->request->is('post')) {
//Create and save the new event in the table.
$this->Event->create();
$this->data['Event']['editable']='1';
if($this->Event->save($data)){
$this->Session->setFlash('GG');
}
else {
$this->Session->setFlash('ERROR');
}
}else{
//Set default duration: 1hr and format to a leading zero.
$hourPlus=intval($hour)+1;
if (strlen($hourPlus)==1) {
$hourPlus = '0'.$hourPlus;
}
//Create a time string to display in view.
if ($allday=='true') {
$event['Event']['allday'] = 1;
$displayTime = 'All day event: ('
. date('D',strtotime($day.'/'.$month.'/'.$year)).' '.
$day.' / '. date("M", mktime(0, 0, 0, $month, 10)).')';
} else {
$event['Event']['allday'] = 0;
$displayTime = date('D',strtotime($day.'/'.$month.'/'.$year)).' '
.$day.' / '.date("M", mktime(0, 0, 0, $month, 10)).
', '.$hour.' : '.$min.' — '.$hourPlus.' : '.$min;
}
$this->set("displayTime",$displayTime);
//Populate the event fields for the add form
$event['Event']['title'] = 'Nom de l\'événement';
$event['Event']['start'] = $year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
$event['Event']['end'] = $year.'-'.$month.'-'.$day.' '.$hourPlus.':'.$min.':00';
$this->set('event',$event);
$this->layout="ajax";
}