?> </div> <div class="col-lg-8"> <?php echo $form->field($model, 'address'); ?> </div> </div> <div class="row"> <div class="col-lg-8"> <?php echo $form->field($model, 'location'); ?> </div> <div class="col-lg-4"> <?php echo $form->field($model, 'driverId')->dropDownList(\app\models\Drivers::driversArr(), ['prompt' => 'Водитель по умолчанию...']); ?> </div> </div> <?php echo $form->field($model, 'comment')->textarea(); ?> <?php echo Html::submitButton('Сохранить', ['class' => 'btn btn-primary pull-right']); ?> </div> </div> </div> <?php ActiveForm::end();
public static function driversArr() { return ArrayHelper::map(Drivers::find()->asArray()->all(), 'id', 'name'); }
function getDrivers() { return $this->hasOne(Drivers::className(), ['id' => 'driverId']); }
public function actionRemove($id) { $model = Drivers::findOne($id); $model->delete(); return $this->redirect(['/drivers/index']); }
<?php echo $form->field($model, $attr)->label(false); ?> <?php } elseif ($attr == 'deliveryId') { ?> <?php echo $form->field($model, $attr)->dropDownList(\app\models\Delivery::deliveryArr())->label(false); ?> <?php } elseif ($attr == 'payment') { ?> <?php echo $form->field($model, $attr)->dropDownList($model->paymentArr)->label(false); ?> <?php } elseif ($attr == 'driverId') { ?> <?php echo $form->field($model, $attr)->dropDownList(\app\models\Drivers::driversArr())->label(false); ?> <?php } ?> <?php echo Html::submitButton(Html::tag('span', '', ['class' => 'glyphicon glyphicon-ok']), ['class' => 'btn btn-primary btn-sm']); ?> <?php ActiveForm::end();