0
js插件DataTables存在一個問題。爲了讓它工作,我實現了Chris Nizzardini的DataTableComponent:https://github.com/cnizzdotcom/cakephp-datatableCakePHP DataTable組件破壞表單驗證
這工作完全正常。但是當我想在包含該DataTable的頁面上保存一個表單時,Cake會拋出一個數據庫錯誤,並且字段的完整性約束違規不能爲空。
我所知道的是: 表單驗證工作正常,在控制器的線
public $components = array('RequestHandler', 'Session', 'DataTable');
改變該行的時候:
public $components = array('RequestHandler', 'Session');
我可以在控制器更改代碼,而不擺脫錯誤,所以我假設在組件中驗證被省略。
控制器代碼:
if (!$this->request->isPost()) {
$this->paginate = array(
'fields' => array('Post.id', 'Post.B/S', 'Post.H', 'Post.DATE', 'Post.TIME', 'Post.INCOME', 'Post.CART'),
'conditions' => array('OR' =>
array(
array('AND' => array(
array('Post.ZIPCODE LIKE' => $userArea . '%'),
array('Post.ALTDATE >' => date("Y-m-d")),
array('Post.AGENT' => '0'),
array('Post.OWNER <>' => $this->UserAuth->getUserId()),
array('Post.PARENTID' => '0'),
array('Post.ACCEPTED' => '0')
)),
array('AND' => array(
array('Post.ZIPCODE' => $userArea . '%'),
array('Post.ALTDATE' => date("Y-m-d")),
array('Post.TIME >' => date("H:i")),
array('Post.AGENT' => '0'),
array('Post.OWNER <>' => $this->UserAuth->getUserId()),
array('Post.PARENTID' => '0'),
array('Post.ACCEPTED' => '0')
)),
array('AND' => array(
array('Post.DELIVERYAREA LIKE' => $userArea . '%'),
array('Post.ALTDATE >' => date("Y-m-d")),
array('Post.AGENT' => '0'),
array('Post.OWNER <>' => $this->UserAuth->getUserId()),
array('Post.PARENTID' => '0'),
array('Post.ACCEPTED' => '0')
)),
array('AND' => array(
array('Post.DELIVERYAREA' => $userArea . '%'),
array('Post.ALTDATE' => date("Y-m-d")),
array('Post.TIME >' => date("H:i")),
array('Post.AGENT' => '0'),
array('Post.OWNER <>' => $this->UserAuth->getUserId()),
array('Post.PARENTID' => '0'),
array('Post.ACCEPTED' => '0')
)),
)
)
);
$response = $this->DataTable->getResponse();
$this->set('response', $response);
$this->set('_serialize','response');
$response['oLanguage'] = array('sUrl' => 'language/dataTables.german.txt');
};
我的問題:有沒有一種可能借道該組件的請求,並獲取該數據,以便數據庫錯誤消失後運行呢?感謝你們。