Hi yii2 developers,
I had installed the yii2 advanced template, but when I integrate an admin template, all was working except the filterModel of the table (when I press ENTER nothing happens), I think it’s because the the style but how I can modify that. It’s working just when I’m use “site.css” yii2 style.
Any suggestions please ?
this is the views/article/index.php code:
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\ArticleSearch;
use backend\models\Article;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ArticleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Articles';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="article-index">
<!-- <h1><?php // Html::encode($this->title) ?></h1> -->
<div class="panel panel-pink">
<div class="panel-heading">Trouver Une Article</div>
<div class="panel-body pan">
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
</div>
</div>
<p>
<?= Html::a('Ajouter une Article', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<div class="panel panel-yellow">
<div class="panel-heading">Les Articles</div>
<div class="panel-body">
<div id="no-more-tables">
<?= GridView::widget([
/*'dataProvider' => $dataProvider,*/
'filterModel' => $searchModel,
'id' => 'table',
'dataProvider' => $dataProvider,
//'layout'=>"{sorter}\n{pager}\n{summary}\n{items}",
//'summary' => $count < 2 ? "" : "Showing {begin} - {end} of {totalCount} items",
'tableOptions' => ['class' => 'table table-bordered table-striped table-condensed cf'],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//'idArticle',
'designationArticle',
'prixArticle',
'poidsArticle',
'quantiteArticle',
//'idUniteArticle0.libelleUniteArticle',
//'idFamilleArticle0.libelleFamilleArticle',
[
'attribute' => 'idUniteArticle',
'value'=> 'idUniteArticle0.libelleUniteArticle',
],
[
'attribute' => 'idFamilleArticle',
'value'=> 'idFamilleArticle0.libelleFamilleArticle',
],
'dateAjoutArticle',
['class' => 'yii\grid\ActionColumn'],
],
//'rowOptions' =>['ng-model'=>'art'],
]); ?>
</div>
</div>
</div>
</div>
and that is the controller
<?php
namespace backend\controllers;
use Yii;
use backend\models\Article;
use backend\models\ArticleSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ArticleController implements the CRUD actions for Article model.
*/
class ArticleController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
/*'index' => ['get'],
'view' => ['get'],
'create' => ['get', 'post'],
'update' => ['get', 'put', 'post'],
'delete' => ['post', 'delete'],*/
],
],
];
}
/**
* Lists all Article models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ArticleSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Article model.
* @param integer $idArticle
* @param integer $idFamilleArticle
* @return mixed
*/
public function actionView($idArticle, $idFamilleArticle)
{
return $this->render('view', [
'model' => $this->findModel($idArticle, $idFamilleArticle),
]);
}
/**
* Creates a new Article model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Article();
if ($model->load(Yii::$app->request->post())) {
$model->dateAjoutArticle= date('Y-m-d h:m:s');
$model->save();
return $this->redirect(['view', 'idArticle' => $model->idArticle, 'idFamilleArticle' => $model->idFamilleArticle]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Article model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $idArticle
* @param integer $idFamilleArticle
* @return mixed
*/
public function actionUpdate($idArticle, $idFamilleArticle)
{
$model = $this->findModel($idArticle, $idFamilleArticle);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'idArticle' => $model->idArticle, 'idFamilleArticle' => $model->idFamilleArticle]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Article model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $idArticle
* @param integer $idFamilleArticle
* @return mixed
*/
public function actionDelete($idArticle, $idFamilleArticle)
{
$this->findModel($idArticle, $idFamilleArticle)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Article model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $idArticle
* @param integer $idFamilleArticle
* @return Article the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($idArticle, $idFamilleArticle)
{
if (($model = Article::findOne(['idArticle' => $idArticle, 'idFamilleArticle' => $idFamilleArticle])) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}