douyingmou1389 2014-01-16 20:37
浏览 24
已采纳

从选择输入提交文本,而不是ID - CakePHP

I have a Select box full of Account names that I retrieve from my CRM with a SOAP call. I send JUST the names to my view when I use the cakePHP FormHelper to create my form. The only issue I'm having is although the select populates properly it sends back the index I've chosen and not the text like i'd like.

echo $this->Form->create();
  echo $this->Form->input('name');
  echo $this->Form->input('email');
  echo $this->Form->input('account');
  echo $this->Form->input('message');
  echo $this->Form->end(__('Submit')); 
echo $this->Form->end();

So does anyone know how to submit the selected value of account and not the ID? Thank you in advance.

  • 写回答

4条回答 默认 最新

  • dongxun6690 2014-01-16 21:19
    关注

    if $accounts is the variable name you are using, you can try

    $accountValues = array();
    foreach ($accounts as $key => $value) {
        $accountValues[$value] = $value;
    } 
    $accounts = $accountValues;
    

    to generate an array that will have both keys and values the same.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料