dongmi1663 2014-11-21 13:20
浏览 35
已采纳

CakePHP下拉表单值未发送到控制器

I have a form with four fields - three of which are properly being sent up to the controller. One field is a drop-down selector field and it is not being sent. Here is sample form code from my schedule_date field which is being sent properly:

<?php
       echo $this->Form->input("schedule_date"
                                ,array('label'             => false
                                      ,'type'              => 'text'
                                      ,'class'             => 'step_dates'
                                      ,'readOnly'          => 'readOnly'
                                       )
                               );
   ?>

And here is the code for the drop-down box which is NOT being sent properly:

<?php
       echo $this->Form->input("project_step_type_id"
                               ,array('label'   => false
                                       ,'id'      => 'project_step_type_id'
                                       ,'class'   => 'project_step_type_id'
                                       ,'empty'   => '( select step )'
                                       ,'options' => $project_step_types
                                                                    )
                                                                );?>

Here is what my debug looks like on the form data I'm sending back (notice project_step_type_id is missing):

    <pre class="cake-debug">
array(
    &#039;user_id&#039; =&gt; &#039;402&#039;,
    &#039;trainer_user_id&#039; =&gt; &#039;524&#039;,
    &#039;schedule_date&#039; =&gt; &#039;2014-11-26&#039;
)
</pre>

Can anyone help? All fields are inside the form tag. I believe the issue is with this line:

            request_data=$('#my_form input').serializeCakeArray();

It's not getting the "select" fields, only the "input" fields. Does anyone know how to fix that? Thank you.

  • 写回答

1条回答 默认 最新

  • dra87370 2014-11-21 14:53
    关注

    The answer is:

    request_data=$('#my_form input, #my_form select').serializeCakeArray();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳