예제 #1
0
 public function actionLists($id)
 {
     $virtual = Virtual::find()->where(['id' => $id])->all();
     foreach ($virtual as $key) {
         echo "<option value='{$key->id}'>{$key->name}</option>";
     }
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Virtual::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'last_update' => $this->last_update]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getVirtual()
 {
     return $this->hasOne(Virtual::className(), ['id' => 'virtual_id']);
 }
예제 #4
0
/* @var $form yii\widgets\ActiveForm */
?>

<div class="out-subsgroup-virtual-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'id' => $model->formName()]);
?>
    <div class="hide">
        <?php 
echo $form->field($model, 'subsgroup_id')->textInput(['value' => $_GET['id'], 'readonly' => 'readonly']);
?>
    </div>

    <?php 
echo $form->field($model, 'virtual_id')->dropDownList(ArrayHelper::map(Virtual::find()->all(), 'id', 'name'), ['prompt' => 'Select Virtual']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton('Search', ['class' => 'btn btn-primary-budi']);
?>
        <?php 
echo Html::resetButton('Reset', ['class' => 'btn btn-default']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
 /**
  * Finds the Virtual model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Virtual the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Virtual::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }