我遇到了CakePHP formbuilder的问题。选项的第一个值必须是1而不是0.
查看:
<div class="form-group">
<label class="col-md-3 control-label" for="competentie">Competenties</label>
<div class="col-md-6">
<?php echo $this->Form->input('competence._ids',['class'=>'form-control ','options'=> $competence,'div'=>false,'label'=>false]); ?>
</div>
</div>
控制器:
$category = $this->Cv->Category->find('list', ['keyField' => 'category_id', 'valueField' => 'category']);
$this->set(compact('cv', 'category'));
$this->set('_serialize', ['cv']);
知道如何让它从价值1开始吗?而不是0。
它的屏幕截图:https://i.gyazo.com/5ebeeeccc11ee08762efd9a84ba357ba.png
答案 0 :(得分:0)
类别表是否有category_id字段? 如果没有,你可能会尝试:
$category = $this->Cv->Category->find('list',
['keyField' => 'id', 'valueField' => 'category']);
否则再次查看调试值并确认数据是否正确。