/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categoryname::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(['category_id' => $this->category_id]);
     $query->andFilterWhere(['like', 'category', $this->category]);
     return $dataProvider;
 }
 /**
  * Finds the Categoryname model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Categoryname the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Categoryname::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#3
0
/* @var $model backend\models\News */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="news-form">

   <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

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

    <?php 
echo $form->field($model, 'category')->dropDownList(ArrayHelper::map(Categoryname::find()->all(), 'category_id', 'category'), ['prompt' => 'Kategori Seç']);
?>

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



<?php 
if ($model->logo) {
    echo '<img src="' . \Yii::$app->request->BaseUrl . '/' . $model->logo . '" width="90px">&nbsp;&nbsp;&nbsp;';
    echo Html::a('Delete Logo', ['deleteimg', 'id' => $model->id, 'field' => 'logo'], ['class' => 'btn btn-danger']) . '<p>';