我使用 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/