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

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
kohinoor
  • 47
  • 11

1 Answers1

3

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

ndm
  • 59,784
  • 9
  • 71
  • 110