/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Prefix::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 3]]); $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(['like', 'prefix_id', $this->prefix_id])->andFilterWhere(['like', 'prefix_name', $this->prefix_name]); return $dataProvider; }
public function searchVirtual($params) { $dreams = ArrayHelper::map(Prefix::find()->where(['virtual_id' => $_GET['id']])->all(), 'id', 'id'); $query = OutTrunkgroupPrefix::find()->where(['in', 'prefix_id', $dreams]); $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, 'out_trunkgroup_id' => $this->out_trunkgroup_id, 'prefix_id' => $this->prefix_id, 'priority' => $this->priority]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function searchVirtual($params) { $query = Prefix::find()->where(['virtual_id' => $_GET['id']]); $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, 'virtual_id' => $this->virtual_id, 'type' => $this->type]); $query->andFilterWhere(['like', 'prefix', $this->prefix])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; use backend\models\Prefix; /* @var $this yii\web\View */ /* @var $model backend\models\OutSubsgroupPrefix */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="out-subsgroup-prefix-form"> <?php $form = ActiveForm::begin(['id' => $model->formName(), 'enableAjaxValidation' => true, 'validationUrl' => Url::toRoute('out-subsgroup-prefix/validation-subsgroup')]); ?> <?php echo $form->field($model, 'prefix_id')->dropDownList(ArrayHelper::map(Prefix::find()->all(), 'id', 'prefix'), ['prompt' => 'Select Prefix']); ?> <div class="hide"> <?php echo $form->field($model, 'subsgroup_id')->textInput(['value' => $model->isNewRecord ? $_GET['id'] : $model->subsgroup_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 ActiveForm::end();
use backend\models\OutTrunkgroup; use backend\models\OutTrunkgroupVirtual; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model backend\models\OutTrunkgroupPrefix */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="out-trunkgroup-prefix-form"> <?php $form = ActiveForm::begin(['id' => 'love', 'enableAjaxValidation' => true, 'validationUrl' => Url::toRoute('out-trunkgroup-prefix/validation-out-trunkgroup')]); ?> <?php echo $form->field($model, 'prefix_id')->dropDownList(ArrayHelper::map(Prefix::find()->where(['virtual_id' => $model->isNewRecord ? $_GET['id'] : $_GET['virtual_id']])->all(), 'id', 'prefix'), ['prompt' => 'Select Prefix']); ?> <?php $out_trunkgroup_ids = OutTrunkgroupVirtual::find('out_trunkgroup_id')->where(['virtual_id' => $model->isNewRecord ? $_GET['id'] : $_GET['virtual_id']])->asArray()->all(); ?> <?php echo $form->field($model, 'out_trunkgroup_id')->dropDownList(ArrayHelper::map(OutTrunkgroup::find()->where(['in', 'id', ArrayHelper::map($out_trunkgroup_ids, 'out_trunkgroup_id', 'out_trunkgroup_id')])->all(), 'id', 'name'), ['prompt' => 'Select Out Trunk Group']); ?> <?php echo $form->field($model, 'priority')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
/** * @return \yii\db\ActiveQuery */ public function getPrefix() { return $this->hasOne(Prefix::className(), ['id' => 'prefix_id']); }
/** * Finds the Prefix model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Prefix the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Prefix::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }