如何从蛋糕php中的下拉列表中获取所选的值 [英] how to get the selected values from a drop down list in cake php

查看:133
本文介绍了如何从蛋糕php中的下拉列表中获取所选的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的蛋糕php。我需要从蛋糕php的下拉列表中获取用户选择的值。我的视图代码是:

  echo $ this-> Form-> create('order'); 
echo $ this-> Form-> input('status',array('options'=> $ options,'default'=>'--Select--'));

请帮助我获取值(不是键)。



 <$> 

您可以使用以下方法获取用户选择的值到控制器的方法中: c $ c> $ selected_value = $ this-> request-> data ['order'] ['status'];

您可以使用以下方式将发布的数据检查到控制器的方法:

  if($ this-> request-> is('post'))
{
pr($ this-> request-> data); die;
$ selected_value = $ this-> request-> data ['order'] ['status'];
}


I’m new to cake php. I need to get the user selected value from a drop down list in cake php. my view code is :

echo $this->Form->create('order');
echo $this->Form->input('status', array('options' => $options, 'default' => '--Select--'));

please help me to get the values(not key).

解决方案

You can simply get the user selected value into your controller's method using:

$selected_value = $this->request->data['order']['status'];

You can either check the posted data into your controller's method using:

if($this->request->is('post'))
{
   pr($this->request->data);die;
   $selected_value = $this->request->data['order']['status'];
}

这篇关于如何从蛋糕php中的下拉列表中获取所选的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆