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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。