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 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗