如何暂停和重启jquery datatables插件(how to pause and restart jquery datatables plugin)
我正试图通过单击按钮来转换表格中的一行。 我的问题是该表使用Datatables插件,我想禁用脚本(过滤,排序ecc。),并在提交后重新激活它。
我现在正在尝试使用bDestroy,同时启用了禁用过滤和排序的新功能,但我想完全禁用该脚本,因为它可能会给我的脚本带来新的问题。
I'm trying to transform a row of my table in a form by clicking a button. My problem is the table uses Datatables plugin, and I would like to disable the script (filtering, sorting ecc.), and reactivate it after submit.
I was trying now to use bDestroy while starting a new istance with filtering and sorting disabled, but I would like to totally disable the script, because it may create new issues to my script.
原文:https://stackoverflow.com/questions/20451305
最满意答案
如果您正在使用cakePHP 2.x,那么您可以在模型的回调函数中设置密码加密,然后在之前保存()
<?php // app/Model/User.php App::uses('AuthComponent', 'Controller/Component'); class User extends AppModel { // ... public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } return true; } ?>
有关更多信息,请点击链接 。 如果您仍想在控制器中加密密码,那么您可以使用类似的代码。
public function add() { $this->set("title_for_layout", "Register"); if($this->request->is("post")) { $this->User->set($this->request->data); if($this->User->save(array("password" => $this->Auth->password($this->request->data["User"]["password"])))) { $this->Session->setFlash(__("Successfully registred."), "flash_success"); $this->redirect("/login"); } else { $this->Session->setFlash(__("Validation failed."), "flash_danger"); } } } ?>
如果您正在使用cakePHP 2.4或更高版本,请按照此处的文档进行操作。
If you're using cakePHP 2.x then you can set password encryption in the model's callback function beforeSave() as
<?php // app/Model/User.php App::uses('AuthComponent', 'Controller/Component'); class User extends AppModel { // ... public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } return true; } ?>
For more information follow the link. IF you still want to encrypt password in the controller then you can use the code like.
public function add() { $this->set("title_for_layout", "Register"); if($this->request->is("post")) { $this->User->set($this->request->data); if($this->User->save(array("password" => $this->Auth->password($this->request->data["User"]["password"])))) { $this->Session->setFlash(__("Successfully registred."), "flash_success"); $this->redirect("/login"); } else { $this->Session->setFlash(__("Validation failed."), "flash_danger"); } } } ?>
If you're using the cakePHP 2.4 or later then follow the documentation here.
相关问答
更多-
虽然这是一个非常糟糕的想法,并打开你的系统进行各种黑客攻击。 您应该在数据库中创建管理员用户。 但是,您实际问题的答案是: identify()不接受任何参数,而是基于当前请求数据进行身份验证,因此如果您没有在数据库中匹配该数据的用户,它将总是返回false。 你想要做的只是调用setUser($getMasterLogin) ,如下所示: if(($data['email'] == 'admin@gmail.com') && ($data['password'] == '123456')) { ...
-
无法登录CakePHP 3(Cannot login in CakePHP 3)[2024-01-18]
您已将Form身份验证器配置为使用email字段来标识用户,但您的表单不使用该字段,它使用username段,因此身份验证者将找不到发布的数据。 也可以看看 Cookbook>控制器>组件>验证>配置验证处理程序 Cookbook>教程与示例> CMS教程 - 身份验证>添加登录 You have configured the Form authenticator to use the email field for identifying the user, but your form doesn't u ... -
在Cake 2.x中,它有点不同 $this->Auth->authenticate = array( 'Form' => array( 'fields' => array('username' => 'email', 'password' => 'password'), ), ); In Cake 2.x it's a little different $this->Auth->authenticate = array( 'Form' => array( ...
-
在CakePHP Auth中允许整个控制器,并允许()不起作用(Allow entire controller in CakePHP Auth and allow() doesn't work)[2021-12-30]
你提出的是你想做什么的适当方式 public function beforeFilter() { $this->Auth->allow(); } 阅读API文档 获取当前控制器中不需要身份验证的操作列表,或者不允许所有操作的参数。 所以没有参数的函数应该允许普通用户(未登录)访问该控制器的每个动作。 编辑: 对不起,您的代码中遗漏了版本参考。 它在这里说 $this->Auth->allow('*'); 是Cake 2.0的合适方式(以及以前的版本,正如@mark所指出的那样) What yo ... -
如果您正在使用cakePHP 2.x,那么您可以在模型的回调函数中设置密码加密,然后在之前保存() data[$this->alias ...
-
CakePHP可能不明白它需要在比较之前对密码字段进行哈希处理,因为你已经重命名了你的字段......这可以通过你可以在字段中输入哈希密码并成功登录来证实...... 'Auth.fields' => array('username' => 'usuario', 'password' => 'passwd'), 尝试将您的数据库列重命名为密码,并确保您在视图中使用FormHelpers来排除这是您的问题。我为糟糕的答案道歉,但这是我可以根据您发布的内容做出的最好的。 如果你回复我的回答,我很乐意改进它。 ...
-
CakePHP 2.1 Auth-> login()不起作用,但是添加用户呢(CakePHP 2.1 Auth->login() not working, but adding user does)[2022-06-29]
我最终解决这个问题的方法是完全按照CakePHP的说法完成教程。 我也升级到2.1.2。 我在运行2.1.0。 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html 然后我慢慢添加了我需要的配置。 有关我引用的Auth组件的信息: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html 真的是我的问题是 ... -
起初我也很困惑地看着蛋糕文档。 但后来我发现了。 您的代码顺序错误。 首先,你必须这样做 $this->Html->addCrumb('Users','/users'); $this->Html->addCrumb('Add User',['controller'=>'Users','action'=>'add 然后是getCrumbs, echo $this->Html->getCrumbs('>', [ 'text'=>$this->Html->image('home.png',['alt'=>'Ho ...
-
我解决了这些问题: 确保服务器上的时间是正确的。 否则会话将无法工作。 修正acos表中的表格数据。 特别要确保'lft'和'rght'值是正确的。 此页面可能有所帮助: http : //www.sitepoint.com/hierarchical-data-database-2/ 您需要将您想要使用的每个动作添加到acos表。 如果你不这样做,你不能做这个动作。 即使你允许孔控制器。 I solved the problems by: Make sure the time on the server i ...
-
我解决了问题...我使用参数为空的函数。 有效 array( 'authorize' => array( 'Actions' => ar ...