yii2
Hide Yii2 GridView Action buttons
You can use [‘class’ => ActionColumn::className(),’template’=>'{view} {update}’ ] on your gridview.
Yii2 : Active Record add Not In condition
Well all query operands seems now merged within in yii\db\QueryInterface::Where() per documentation an In condition can now be added using something like $query = MyModel::find()->where([‘attribute’=>$array]); for a not In condition it is slightly different format $query = MyModel::find()->where([‘not in’,’attribute’,$array]);
Hide label for input field
Ok, I found the solution. <?= $form->field($model, ‘sample_text’)->textArea()->label(false) ?>
Yii2 Session, Flash messages
To set flash,try like \Yii::$app->getSession()->setFlash(‘error’, ‘Your Text Here..’); return $this->redirect(‘Your Action’); And to display it.. <?= Yii::$app->session->getFlash(‘error’); ?>
Execute my code before any action of any controller
In case you need to execute a code before every controller and action, you can do like below: 1 – Add a component into your components directory, for example(MyGlobalClass): namespace app\components; class MyGlobalClass extends \yii\base\Component{ public function init() { echo “Hi”; parent::init(); } } 2 – Add MyGlobalClass component into your components array in config … Read more