Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cakephp 删除选择框的空值_Cakephp - Fatal编程技术网

Cakephp 删除选择框的空值

Cakephp 删除选择框的空值,cakephp,Cakephp,我有一个这样的选择框 $form->select('city_id',$city,array('empty'=>false,'selected'=>'1', 'label'=>false),数组('label'=>false,'div'=>false,'name'=>city\u id', ‘id’=>‘city_id’) 我需要删除选项顶部的空选项。我甚至设置了 'empty'=>false'但它不起作用 有人能帮我吗 <?php echo $this->Form->inpu

我有一个这样的选择框

$form->select('city_id',$city,array('empty'=>false,'selected'=>'1', 'label'=>false),数组('label'=>false,'div'=>false,'name'=>city\u id', ‘id’=>‘city_id’)

我需要删除选项顶部的空选项。我甚至设置了 'empty'=>false'但它不起作用

有人能帮我吗


<?php echo $this->Form->input('foo.bar', array('type' => 'select', 'options' => array(1 => 'foo', 2 => 'bar'), 'empty' => false)); ?>

对我来说很有用。

看起来你把你的参数弄乱了$form->select()

第一个是字段名,第二个是供用户选择的select选项的键/值数组,第三个参数应该是所选元素值(或null),第四个参数是选项数组,在这里可以包含
'empty'=>false

select(string $fieldName, array $options, mixed $selected, array $attributes)

请参阅CakePHP食谱中的。

链接现在不起作用。请将其更新到current@swapnesh现在,更新了指向docs 1.3版本的链接。您的CakePHP是哪个版本?对我来说,它看起来像CakePHP1.x。请确保您正在查看正确的文档。