我需要返回表單驗證,因爲我提交如何返回表單驗證回在CakePHP
我是在新聞/瀏覽/ 30之後失去了它---查看報告的詳細信息---- 在該頁面,我們有新增評論形式:
<h2>Add comment</h2>
<?php
echo $this->Form->create("Comment", array(
'url' => array('controller' => 'Comments', 'action' => 'add')
));
echo $this->Form->label("name");
echo $this->Form->input("name", array("label" => false, "class" => "textfield"));
echo $this->Form->label("email");
echo $this->Form->input("email", array("label" => false, "class" => "textfield"));
echo $this->Form->label("text");
echo $this->Form->textarea("text", array("label" => false));
echo $this->Form->input("object_id", array("type" => "hidden", "value" => $data['News']['id']));
echo $this->Form->input("type", array("type" => "hidden", "value" => "news"));
echo $this->Html->Link("Add Comment", "#", array("class" => "add_button", "onclick" => "$('#CommentViewForm').submit()"));
echo $this->Form->end();
?>
形式註釋控制器上submiting:
在評論/加:
$isSuccess = $this->Comment->save($this->request->data);
if ($isSuccess) {
$this->Session->setFlash('your Comments has been added successfully and pending admin aproval.thanks ', 'default', array(), 'good');
} else {
$this->Session->setFlash('Failed to add your comment: <br/>Fill all the required fileds <br/>type correct Email', 'default', array(), 'bad');
}
$this->redirect(array("controller" => "News", "action" => "view", $id));
我做的姓名,電子郵件和註釋本身 一些驗證規則,當有用戶輸入錯誤返回添加評論的形式,但沒有顯示錯誤照常
我希望你明白我的爲人,我等待你的幫助,感謝 很多
感謝所有,但。有沒有任何意見評論/添加,所以如果沒有重定向我會錯過視圖錯誤? – oofy 2013-04-04 19:48:08
嘗試在重定向函數之前獲得錯誤後,回顯此$ this-> request-> data'。 即。 '的print_r($這 - >請求 - >數據);退出;' 你可能會得到一些有用的東西。 – MaNKuR 2013-04-05 07:16:07