/** * @return \yii\db\ActiveQuery */ public function getNetwork() { return $this->hasOne(SocialNetworks::className(), ['id' => 'network_id']); }
use yii\widgets\ActiveForm; use frontend\models\SocialNetworks; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model frontend\models\SocialAccount */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="social-account-form"> <?php $form = ActiveForm::begin(); ?> <?php $networks = SocialNetworks::find()->all(); $items = ArrayHelper::map($networks, 'id', 'title'); echo $form->field($model, 'network_id')->dropDownList($items); ?> <?php echo $form->field($model, 'relative_id')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'url')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);