0

Here I'm stuck with one point when I open any form than i want to enable to choose one dropdown but if I want to update that from this dropdown field will be disabled. So Which syntax I put in the form?

$form->field($model, 'branch_id', [])->dropdownList(BranchMaster::getBranchList(Common::getCurrentCompany()),
   [
    'class' => 'chosen-select-width branch_id', 
    'prompt' => Common::translateText('BRANCH_TEXT')
   ]
 );

here is my form field ,now i want it to disable when this form is open for update action.

Insane Skull
  • 9,220
  • 9
  • 44
  • 63

1 Answers1

2

Try this:

<?= $form->field($model, 'branch_id', [])->dropdownList(BranchMaster::getBranchList(Common::getCurrentCompany()), [
    'class' => 'chosen-select-width branch_id',
    'prompt' => Common::translateText('BRANCH_TEXT'),
    'disabled' => !$model->isNewRecord,
]) ?>
arogachev
  • 33,150
  • 7
  • 114
  • 117
Insane Skull
  • 9,220
  • 9
  • 44
  • 63