0
我想获得选定的schoolFilter表单值并放置在[SELECTED VALUE HERE]中。cakephp将选择传递给JS Helper
$data = $this->Js->get('#SchoolFilter')->serializeForm(array('isForm' => true, 'inline' => true));
$this->Js->get('#SchoolSchoolId')->event(
'change', $this->Js->request(
array('action' => 'assign_school_ads/', [SELECTED VALUE HERE], array(
'update' => '#results',
'data' => $data,
'async' => true,
'dataExpression' => true,
'method' => 'POST'
)
)
);
// School Filter
$schoolFilter = $this->Form->create('School', array('id' => 'SchoolFilter');
$schoolFilter .= $this->Form->input('school_id', array('label'=>'Schools', 'empty'=>'- select -');
$schoolFilter .= $this->Form->end();
我看到了这个问题的变化,但没有任何明确的答案,除了忘记使用JS Helper。在JS Helper的上下文中可能吗?如果没有,我可以使用常规JQuery获取值,然后将其注入到JS Helper中。
Shweta,我已经有你建议的代码(请参阅我的代码),它可以正常提交数据。我想获取选择的选定值并将其作为参数与动作一起发送:array('action'=>'assign_school_ads /',[SELECTED VALUE HERE] – drpudding 2013-03-14 17:02:41
也许我没有明确指出发送所选内容值作为参数,因为选择的值可以在你的函数中作为$ this-> data ['your-controller-name'] ['field-id']作为serializeForm访问,就像在表单提交后发送数据到你的函数一样 – 2013-03-15 05:29:51
例如,我试图将AJAX POST操作重写为:assign_school_ads/3,其中3是选择菜单值。这不起作用:array('action'=>'assign_school_ads',$ this-> data [ 'School'] ['school_id']看起来$ data在这种格式下不可用于Helper,直到AJAX发生之后,我知道我可以在控制器中获得$ data,但是想知道是否有任何方法可以使用行动来完成同样的事情。 – drpudding 2013-03-15 16:18:31