dongrang9300
dongrang9300
2017-01-14 18:13

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 dongquanyu5816 4年前

    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.

    点赞 评论 复制链接分享