php - 动态添加的字段不在 $this->request->data 中

标签 php jquery mysql cakephp

我使用 jquery 克隆一些输入字段,但它们没有显示在发布请求中。我在某处读到,这是因为验证,并且不是使用 FormHelper 创建的字段已从请求中删除。

我添加

$this->Security->validatePost=false;

到 beforeFilter 函数,但现在我收到这些错误消息。有人可以帮助我吗:)?

编辑:图像到文本,不可读=)

Notice (8): Indirect modification of overloaded property LabelsController::$Security has no effect [APP\Plugin\ContentConfigurator\Controller\LabelsController.php, line 116]
Code Context
    {

        parent::beforeFilter();

        $this->Security->validatePost=false;
LabelsController::beforeFilter() - APP\Plugin\ContentConfigurator\Controller\LabelsController.php, line 116
call_user_func - [internal], line ??
CakeEventManager::dispatch() - CORE\Cake\Event\CakeEventManager.php, line 242
Controller::startupProcess() - CORE\Cake\Controller\Controller.php, line 674
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 187
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 165
[main] - APP\webroot\index.php, line 108
Warning (2): Creating default object from empty value [APP\Plugin\ContentConfigurator\Controller\LabelsController.php, line 116]
Code Context
    {

        parent::beforeFilter();

        $this->Security->validatePost=false;
LabelsController::beforeFilter() - APP\Plugin\ContentConfigurator\Controller\LabelsController.php, line 116
call_user_func - [internal], line ??
CakeEventManager::dispatch() - CORE\Cake\Event\CakeEventManager.php, line 242
Controller::startupProcess() - CORE\Cake\Controller\Controller.php, line 674
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 187
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 165
[main] - APP\webroot\index.php, line 108

按照 ndm 的要求,过滤器函数来自: LabelsController.php

public function beforeFilter()
{
    parent::beforeFilter();
    $this->Security->validatePost=false;
}

AppController.php

public function beforeFilter() {
    parent::beforeFilter();

    $this->Auth->allow('login');

    // Check if the model isset.
    if (empty($this->model)) {
        throw new FatalErrorException('De huidige controller heeft geen model opgegeven.');
    }

    // Set the layout to 'ajax' when the request is ajax.
    if ($this->request->is('ajax')) {
        $this->layout = 'ajax';
        $this->autoRender = false;
    }
}

最佳答案

安全组件未添加到公共(public) $components 数组中。

class Controller extends AppController
{
    public $components = array('Security');
}

关于php - 动态添加的字段不在 $this->request->data 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28961126/

相关文章:

mysql - Mysql查找跨行的日期范围

php - 从 guzzle 捕获异常

jquery查找具有相同类的所有元素,找到后停止

php - 丢失第二页上的数据库 session 数据

javascript - jQuery .map() 问题

Jquery将div动画到与另一个div相同的位置

php - 连接表时字段列表中的列不明确 codeigniter

php - Symfony 2 - 在 Amazon S3 上上传图像的最佳实践

php - 如何在 PHP 脚本交互中输入重音词?

php - Doctrine——如何在两个实体之间建立一对一的关系