/**
  * Finds the KskCategories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return KskCategories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = KskCategories::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
use yii\helpers\ArrayHelper;
use zxbodya\yii2\galleryManager\GalleryManager;
use mihaildev\ckeditor\CKEditor;
/* @var $this yii\web\View */
/* @var $model backend\models\KskPosts */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="ksk-posts-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
$listCategories = ArrayHelper::map(KskCategories::find()->orderBy('name')->all(), 'id', 'name');
?>

    <!--?= $form->field($model, 'category_id')->textInput(['maxlength' => true]) ?-->
    <?php 
echo $form->field($model, 'category_id')->dropDownList($listCategories, ['prompt' => 'Выберите категорию...']);
?>

    <!--?= $form->field($model, 'title')->textarea(['rows' => 6]) ?-->
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <!--?= $form->field($model, 'content')->textarea(['rows' => 8]) ?-->
    <?php 
echo $form->field($model, 'content')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'full', 'inline' => false]]);
示例#3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(KskCategories::className(), ['id' => 'category_id']);
 }