js-plugin 数据表存在问题。为了让它工作,我实现了 Chris Nizzardini 的 DataTableComponent:https ://github.com/cnizzdotcom/cakephp-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');
};
我的问题:是否有可能通过组件路由请求并在获取该数据后运行它以使数据库错误消失?谢谢你们。