/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = OutTrunkgroup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); 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(['id' => $this->id, 'first_update' => $this->first_update, 'last_update' => $this->last_update, 'virtual_id' => $this->virtual_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'first_user', $this->first_user])->andFilterWhere(['like', 'first_ip', $this->first_ip])->andFilterWhere(['like', 'last_user', $this->last_user])->andFilterWhere(['like', 'last_ip', $this->last_ip]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getOutTrunkgroup() { return $this->hasOne(OutTrunkgroup::className(), ['id' => 'out_trunkgroup']); }
use backend\models\OutTrunkgroup; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model backend\models\OutTrunkgroupVirtual */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="out-trunkgroup-virtual-form"> <?php $form = ActiveForm::begin(['id' => $model->formName(), 'enableAjaxValidation' => true, 'validationUrl' => Url::toRoute('out-trunkgroup-virtual/validation')]); ?> <?php echo $form->field($model, 'out_trunkgroup_id')->dropDownList(ArrayHelper::map(OutTrunkgroup::find()->all(), 'id', 'name'), ['prompt' => 'Select Out Trunk Group']); ?> <div class="hide"> <?php echo $form->field($model, 'virtual_id')->textInput(['value' => $model->isNewRecord ? $_GET['id'] : $model->virtual_id]); ?> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php
/** * Finds the OutTrunkgroup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return OutTrunkgroup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = OutTrunkgroup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }