示例#1
0
 /**
  * Updates an existing CmsRecipes model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id, $category_id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', 'Successfully updated.');
         return $this->redirect(['cms-recipes/update', 'id' => $model->id, 'category_id' => $category_id]);
     }
     $languages = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     $categoryModel = CmsRecipesCategories::findOne($category_id);
     return $this->render('update', ['model' => $model, 'languages' => $languages, 'languageDefault' => $languageDefault, 'categoryModel' => $categoryModel]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CmsRecipesCategories::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, 'status' => $this->status, 'sort_order' => $this->sort_order, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
示例#3
0
 /**
  * Displays a single CmsRecipes model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($category_id, $id)
 {
     $model = $this->findModel($id);
     $category = CmsRecipesCategories::findOne(['id' => $category_id]);
     return $this->render('view', ['model' => $model, 'category' => $category]);
 }
示例#4
0
文件: index.php 项目: skamnev/members
use yii\grid\GridView;
use backend\models\CmsRecipesCategories;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Recipes Categories');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="cms-recipes-categories-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Create Category'), ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a(Yii::t('backend', 'Create Recipe'), ['cms-recipes/create'], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'title', ['attribute' => 'status', 'filter' => Html::activeDropDownList($searchModel, 'status', CmsRecipesCategories::dropdownActive(), ['class' => 'form-control', 'prompt' => Yii::t('backend', 'All')]), 'value' => 'statusLabel'], 'sort_order', ['class' => 'yii\\grid\\ActionColumn', 'urlCreator' => function ($action, $model, $key, $index) {
    return $action == 'view' ? ['cms-recipes-categories/' . $action, 'category_id' => $model['id']] : ['cms-recipes-categories/' . $action, 'id' => $model['id']];
}]]]);
?>

</div>
 /**
  * Finds the CmsRecipesCategories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CmsRecipesCategories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CmsRecipesCategories::find()->where(['id' => $id])->multilingual()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
文件: _form.php 项目: skamnev/members
    $field_meta_keywords = $form->field($model, "meta_keywords_{$language->url}")->textarea(['rows' => 4])->label(Yii::t('backend', 'Recipe Keywords'));
    $field_meta_description = $form->field($model, "meta_description_{$language->url}")->textarea(['rows' => 6])->label(Yii::t('backend', 'Recipe Description'));
    if ($languageDefault->url == $language->url) {
        $field_title = $form->field($model, "title")->textInput(['maxlength' => true]);
        $field_content = $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className(), ['clientOptions' => $redactorClientOptions]);
        $field_content_heading = $form->field($model, "content_heading")->textInput(['maxlength' => true]);
        $field_meta_keywords = $form->field($model, "meta_keywords")->textarea(['rows' => 4]);
        $field_meta_description = $form->field($model, "meta_description")->textarea(['rows' => 6]);
    }
    $language_items[] = ['label' => Yii::t('backend', $language->name), 'content' => "<p>{$field_title} {$field_content} {$field_content_heading} {$field_meta_keywords}</p>", 'active' => $language->url == Yii::$app->language];
}
echo Tabs::widget(['items' => $language_items]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\backend\models\CmsRecipesCategories::find()->all(), 'id', 'title'), ['multiple' => 'true', 'size' => 7])->label(Yii::t('backend', 'Select Categories'));
?>

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

    <?php 
echo $form->field($model, 'code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => Yii::t('backend', 'Select Codes')]);
?>

    <?php 
echo $form->field($model, 'no_code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => Yii::t('backend', 'Select Codes')]);
?>

    <?php