kohinoor
kohinoor

Reputation: 47

How to make multiple values selected in dropdown in cakephp 3.x

<div class="form-group">
   <?php
   echo $this->Form->input('area', array('label' => false,
       'placeholder' => 'Enter Zone Name',
       'type' => 'select',
       'class' => 'form-control',
       'id'=>'area',
       'multiple' => 'multiple',
       'options' => $areaList)
   );
   ?>
</div>

This is my dropdrop for input type select on edit page.

I just want to know how can I make $arealist values to be shown selected.

I am using Cakephp 3.x. I am new to cakephp 3.x.

Upvotes: 2

Views: 2159

Answers (1)

ndm
ndm

Reputation: 60503

Pass the keys of $areaList (which should be a find('list') style resultset/array) to either the default option (which will be used unless the form context contains data for the field, for example the submitted form data), or to the value option (which will hard-select the given values, ie possible form context data will not override it).

// ...
'options' => $areaList,
'default' => array_keys($areaList)

See also

Upvotes: 3

Related Questions