我有两个选择按钮,并希望过滤记录,当用户选择任何选项时,我必须触发一个事件并将按钮的值传递给控制器的操作。我的代码如下所示
视图
<?php echo $this->Form->create('Employee'); ?>
<fieldset>
<div class="pure-control-group">
<?php echo $this->Form->input('designation', array("label" => "Designation",'type' => 'select', 'id'=>'DesignationType','options' => $settings,'empty' => 'select'));?>
<?php echo $this->Form->input('district', array("label" => "District",'type' => 'select', 'id'=>'districtType','options' => $district,'empty' => 'select'));?>
</div>
</fieldset>
<?php echo $this->Form->end();
$this->Js->get('#DesignationType')->event('change',
$this->Js->request(array(
'controller'=>'employees',
'action'=>'getByCategory'
), array(
'update'=>'#success',
'async' => true,
'method' => 'post',
'dataExpression'=>true,
'data'=> $this->Js->serializeForm(array(
'isForm' => true,
'inline' => true
))
))
);
?>
<div id="success"></div>控制器
public function getByCategory(){
$design_id =$this->request->data['Employee']['designation'];
$district_id =$this->request->data['Employee']['district'];
$this->layout = 'ajax';
}当我单击“指定”时,我就可以得到指定的值,但不能得到地区.And的值,然后出现错误。
未定义索引:地区APP\Controller\EmployeesController.php,第18行
那么,如何才能得到区域的价值;
发布于 2014-02-07 09:27:30
尝试在数据变量中发送form id。那是
试试这个:
$data = $this->Js->get('#YourFormId')->serializeForm(array('isForm' => true, 'inline' => true));
$this->Js->get('#DesignationType')->event('change',
$this->Js->request(array(
'controller'=>'employees',
'action'=>'getByCategory'
), array(
'update'=>'#success',
'async' => true,
'method' => 'post',
'dataExpression'=>true,
'data'=> $data
))
);https://stackoverflow.com/questions/21621970
复制相似问题