dongrang9300 2017-01-14 18:13
浏览 25
已采纳

CakePHP 3.3 - Formbuilder的第一个值为1

I got a problem with CakePHP formbuilder. The first value of the options have to be 1 instead of 0.

View:

    <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>

Controller:

    $category = $this->Cv->Category->find('list', ['keyField' => 'category_id', 'valueField' => 'category']);
    $this->set(compact('cv', 'category'));
    $this->set('_serialize', ['cv']);

Any idea how i can make it start at value 1? Instead of 0.

Screenshot of it: https://i.gyazo.com/5ebeeeccc11ee08762efd9a84ba357ba.png

  • 写回答

1条回答 默认 最新

  • dongquanyu5816 2017-01-14 18:37
    关注

    Does categories table have category_id field ? If not you may trying to do:

     $category = $this->Cv->Category->find('list', 
     ['keyField' => 'id', 'valueField' => 'category']);
    

    Otherwise look at the debug value one more time and confirm if data are coming correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?