【发布时间】:2013-03-04 12:09:27
【问题描述】:
提交数据只会重新加载页面,CakePHP 不会给出任何错误或消息。 代码遵循与博客教程相同/相似的结构。
查看代码
<?php
echo $this->Form->create('Sm');
echo $this->Form->input('recievers', array('rows' => '1'));
echo $this->Form->input('subject');
echo $this->Form->input('message');
echo $this->Form->end('SEND');
?>
控制器代码
public function send() {
if ($this->request->is('sm')) {
$this->Sm->create();
if ($this->Sm->save($this->request->data)) {
$this->Session->setFlash('Sms has been added to the database');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('Unable to send sms.');
}
}
}
型号代码
class Sm extends AppModel {
public $validate = array(
'subject' => array(
'rule' => 'notEmpty'
),
'message' => array(
'rule' => 'notEmpty'
),
'recievers' => array(
'rule' => 'notEmpty'
)
); }
导出的 SQL
CREATE TABLE IF NOT EXISTS `sms` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`subject` varchar(150) DEFAULT NULL,
`message` text,
`sender` varchar(50) DEFAULT NULL,
`recievers` text,
`sent` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
【问题讨论】:
-
对这个问题投了赞成票,因为我看不出这个问题获得负分的直接原因。包含所有必需的代码,格式整齐,OP 正在尝试根据手册中的示例启动 CakePHP。
-
谢谢好心的先生 :) 至于问题,我最后的回答是改用烘焙工具生成代码。以下建议的答案都没有成功。可能会花一些时间将我的原始代码与生成的代码进行比较以找到正确的答案。