/** * Creates data provider instance with search query applied * * @return ActiveDataProvider */ public function search() { $query = DeployServer::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public function getDeployServer() { return $this->hasOne(DeployServer::className(), ['_id' => 'deployServerId']); }
use yii\helpers\ArrayHelper; use yii\helpers\Url; /** * @var $this \yii\web\View * @var $model \frontend\models\vks\Request */ ?> <div class="row"> <?php $form = ActiveForm::begin(['id' => 'deploy-server-form', 'action' => Url::to(['set-deploy-server', 'id' => (string) $model->primaryKey])]); ?> <?php $servers = DeployServer::find()->asArray()->all(); $items = ArrayHelper::map($servers, function ($item) { return (string) $item['_id']; }, 'name'); ?> <?php echo $form->field($model, 'deployServerId', ['options' => ['class' => 'col-lg-4']])->dropDownList($items, ['id' => 'deploy-server-id', 'prompt' => $model->getAttributeLabel('deployServerId')])->label(false); ?> <?php ActiveForm::end(); ?> </div>
public function actions() { return ['index' => ['class' => SearchAction::className(), 'modelClass' => VksDeployServerSearch::className()], 'create' => ['class' => CreateAction::className(), 'modelClass' => DeployServer::className()], 'update' => ['class' => UpdateAction::className(), 'modelClass' => DeployServer::className()], 'delete' => ['class' => DeleteAction::className(), 'modelClass' => DeployServer::className()]]; }