예제 #1
0
 public function fields()
 {
     $fields = parent::fields();
     if (Yii::$app->user->isGuest) {
         unset($fields['status'], $fields['created_by'], $fields['updated_by']);
     }
     return $fields;
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PageModel::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
예제 #3
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #4
0
echo $form->field($model, 'sn_image')->fileInput();
?>

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

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

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

    <?php 
echo $form->field($model, 'status')->dropDownList(Page::getStatuses());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
예제 #5
0
use yii\widgets\ActiveForm;
use app\models\blog\Row;
use app\models\blog\Page;
/* @var $this yii\web\View */
/* @var $model app\models\blog\Row */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="row-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'page_id')->dropDownList(ArrayHelper::map(Page::getActive(), 'id', 'title'));
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(array_merge([0 => 'Нет'], ArrayHelper::map(Row::getActive(), 'id', 'title')));
?>

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

    <?php 
echo $form->field($model, 'fullWidth')->dropDownList([0 => 'Нет', 1 => 'Да']);
?>

    <?php 
예제 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPage()
 {
     return $this->hasOne(Page::className(), ['id' => 'page_id']);
 }