Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cp::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]);
     $query->andFilterWhere(['like', 'cp_name', $this->cp_name]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCp()
 {
     return $this->hasOne(Cp::className(), ['id' => 'cp_id']);
 }
Ejemplo n.º 3
0
 /**
  * Finds the Cp model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cp the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cp::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
?>

    <?php 
echo $form->field($model, 'app_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'app_code')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'version')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'cp_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Cp::find()->all(), 'id', 'cp_name'));
?>

    <?php 
echo $form->field($model, 'active')->dropDownList([1 => '激活', 0 => '不激活']);
?>
    <?php 
echo $form->field($model, 'api_url')->textInput(['maxlength' => true]);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', '新增') : Yii::t('app', '修改'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php