コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Template::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', 'name', $this->name])->andFilterWhere(['like', 'file_name', $this->file_name]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Page.php プロジェクト: nootropil/template_yii2
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTemplate()
 {
     return $this->hasOne(Template::className(), ['id' => 'template_id']);
 }
コード例 #3
0
 /**
  * Finds the Template model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Template the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Template::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
ファイル: _form.php プロジェクト: nootropil/template_yii2
echo $form->field($model, 'seo_title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'seo_description')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'seo_keywords')->textarea(['rows' => 6]);
?>

    <div class="row">
        <div class="col-md-6">
            <div class="form-group">
                <?php 
echo Html::activeDropDownList($model, 'template_id', ArrayHelper::map(Template::find()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Выберите шаблон']);
?>
            </div>
        </div>
    </div>

    <?php 
echo $form->field($model, 'index_page')->checkbox(['disabled' => $model::getIndexPage() !== null && $model->id !== $model::getIndexPage()->id]);
?>

    <?php 
echo $form->field($model, 'in_menu')->checkbox();
?>

    <div class="row">
        <div class="col-md-6">