视图
<?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 submit实际上返回同一模型的新表单字段。下面是首先为ajax
发送表单的视图echo $this->Form->input('Practice.options',array('value'=>'regex value'));
新字段值未以表单
提交答案 0 :(得分:2)
我做了两个错误,首先是新的ajax返回的字段不在表单标签中,我需要绕过cakephp安全检查
function beforeFilter() {
parent::beforeFilter();
$this->Security->blackHoleCallback = 'blackhole';
$this->Security->csrfCheck = false;
$this->Security->validatePost = false;
$this->set('contentLayout', 'admin_dashboard');
}
答案 1 :(得分:0)
确保您在表单末尾放置
<?php echo $this->Form->end(); ?>
然后解锁SecurityComponent的当前操作