3

风景

<?php echo $this->Form->create('Practice');
echo $this->Form->input('title',array('value'=>'test value'));
echo $this->Js->submit('Ajax Submit', array(
'update' => '#left',
 'url'=>'/practices/content',
 'async' => true,
 'method' => 'post',
 'dataExpression'=>true,
 'data'=> $this->Js->serializeForm(array(
     'isForm' => true,
     'inline' => true 

  ))
    ));
?> <?php echo $this->Form->end(); ?>

表单在 Ajax 提交之前工作正常。ajax 提交实际上返回相同模型的新表单字段。下面是首先为 ajax 发送表单的视图

echo $this->Form->input('Practice.options',array('value'=>'regex value'));

新字段值未与表单一起提交

4

2 回答 2

2

我犯了两个错误,首先是新的 ajax 返回的字段不在表单标签内,其次我需要绕过 cakephp 安全检查

function beforeFilter() {
        parent::beforeFilter();
        $this->Security->blackHoleCallback = 'blackhole';
        $this->Security->csrfCheck = false;
        $this->Security->validatePost = false;
        $this->set('contentLayout', 'admin_dashboard');
    }
于 2013-09-26T13:22:55.143 回答
0

确保您在表格末尾放置

<?php echo $this->Form->end(); ?>

然后您解锁 SecurityComponent 的当前操作

于 2013-09-08T19:00:47.710 回答