Nit*_*ish 3 cakephp default-value selection
我是cakephp的新手.我需要添加一个默认值
<option value="0">--Please Select--</option>
Run Code Online (Sandbox Code Playgroud)
在我的以下选择字段中:
$attributes = array("empty"=>false,"Selected" => 'Select City',"id" => "location");
echo $form->select("gal_location_id", $gal_locations,null,$attributes);
Run Code Online (Sandbox Code Playgroud)
我试着补充一下
$gal_locations[0] = "--Select City--";
$attributes = array("empty"=>false,"default" => 0,"id" => "location");
Run Code Online (Sandbox Code Playgroud)
但选项位于列表的底部.添加默认选项的正确方法是什么?
Dav*_*ave 14
您正在寻找"空"属性:
$this->Form->input('gal_location_id', array(
'type' => 'select',
'options' => $gal_locations,
'empty' => 'Select City', // <-- Shows as the first item and has no value
'id' => 'location'
));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9291 次 |
最近记录: |