Php 选择带有表单::select的选项
我想用方法Php 选择带有表单::select的选项,php,kohana,Php,Kohana,我想用方法Form::select制作一个数组的下拉列表。下拉列表是动态生成的,因此所选项目可以更改 我制定了以下代码: echo Form::select('nomselect', $noms_sols, $_GET['id_region'], array('onchange'=>"", 'id' => 'select_sols',
Form::select
制作一个数组的下拉列表。下拉列表是动态生成的,因此所选项目可以更改
我制定了以下代码:
echo Form::select('nomselect',
$noms_sols,
$_GET['id_region'],
array('onchange'=>"",
'id' => 'select_sols',
'selected' => $systeme['nom_sol']));
下拉列表正在运行,但我没有所需的选定项。在代码的最后一行,我尝试了一些东西,但不起作用
有办法吗?还是我必须使用foreach
方法?
提前感谢。方法的第三个参数是选定项。在您的例子中,$\u GET['id\u region']的值也应该在$noms\u sols数组中
例如,这应该在值为2的选项上添加选定的属性
$noms_sols = array("1", "2", "3");
$id_region = $_GET['id_region']; // $id_region == "2"
echo Form::select('nomselect',
$noms_sols,
$id_region);
方法的第三个参数是选定项。在您的例子中,$\u GET['id\u region']的值也应该在$noms\u sols数组中
例如,这应该在值为2的选项上添加选定的属性
$noms_sols = array("1", "2", "3");
$id_region = $_GET['id_region']; // $id_region == "2"
echo Form::select('nomselect',
$noms_sols,
$id_region);
“表单”类来自哪里?任何框架?@Random它来自一个框架(我忘了标记它:S),那么它使用什么框架?@AndrewRayner它使用kohana“Form”类来自哪里?任何框架?@Random它来自一个框架(我忘了标记它:S),那么它使用什么框架呢?@AndrewRayner它使用Kohana