在我的应用程序中,我正在使用安全组件并像这样在应用程序控制器中定义
public $components = array('Security');
我已经创建了这样的表格
<?php
echo $this->Form->create('Admin', array('id' => 'form',"url"=>array("plugin"=>"admins","controller"=>"admins","action"=>"save","admin"=>true)));
echo $this->Form->hidden("submit_type",array("id" => "id_submit_type","value" => ""));
echo $this->Form->input("username");
echo $this->Form->input("password");
echo $this->Form->button(__('Save'),array("id" => "save","class" => "form-button"));
echo $this->Form->button(__('Save & Cont'),array("id" => "savec","class" => "form-button"));
echo $this->Form->end();
?>
在 Javascript 中,我正在像这样更新隐藏字段值
<script type="text/javascript">
$(document).ready(function()
{
$('#save, #savec').click(function() {
if($(this).is('#save'))
$('#id_submit_type').val("S");
else
$('#id_submit_type').val("C");
$('#form').submit();
});
});
</script>
点击保存按钮后
CORE/Cake/Controller/Component/SecurityComponent.php line 234 → SecurityComponent->blackHole(AdminsController, string)
[internal function] → SecurityComponent->startup(AdminsController)
CORE/Cake/Utility/ObjectCollection.php line 131 → call_user_func_array(array, array)
[internal function] → ObjectCollection->trigger(CakeEvent)
CORE/Cake/Event/CakeEventManager.php line 247 → call_user_func(array, CakeEvent)
CORE/Cake/Controller/Controller.php line 670 → CakeEventManager->dispatch(CakeEvent)
CORE/Cake/Routing/Dispatcher.php line 183 → Controller->startupProcess()
CORE/Cake/Routing/Dispatcher.php line 161 → Dispatcher->_invoke(AdminsController, CakeRequest, CakeResponse)
APP/webroot/index.php line 97 → Dispatcher->dispatch(CakeRequest, CakeResponse)
如果我评论更新 javascript 中的隐藏字段
我的功能工作正常并将数据保存到表中
请告诉我在我们使用安全组件时如何在 javascript 中设置隐藏变量值