yii2-basic-app

Yii2 - How to set dynamic authTimeout in User Identity?

半世苍凉 提交于 2019-12-22 09:46:26
问题 Here, I have extended User Identity of Yii2. This is my configuration. 'user' => [ 'identityClass' => app\models\UserMaster::class, 'enableAutoLogin' => false, 'loginUrl' => ['/auth/login'], 'authTimeout' => 86400 ], Here, I have defined authTimout statically. But, What I want to do is that I want to fetch timeout value from database and set it in authTimeout . Thanks. 回答1: You can use event to set authTimeout before request will be handled: 'as beforeRequest' => [ 'class' => function (Event

Regarding GridView Filter in yii2

瘦欲@ 提交于 2019-12-16 18:02:13
问题 I have a table like this with 5 columns. TableName -Column1 -Column2 -Column3 -Column4 -Column5 I had merged them to display them in grid view as single column. Question How can i make filter condition query to search them based on user input.? Eg.User types something as input, it have search from all the 5 columns and return the result based on the search input.(Sorting works fine, please help me with filtering) If someone could helpme it would be great, Thanks. UPDATE: $query-

Yii2 notification widget class not found

不羁岁月 提交于 2019-12-14 02:22:18
问题 I'm trying to use "machour's" notification widget But somehow I can't even call class: NotificationWidget in my code It says that "Class is not found" I'm using yii2-basic-template, how can I call that Class ? edit: i tried to create directory: backend/components and tried use backend/components/Notification; But i use basic template so i don't think it's right https://github.com/machour/yii2-notifications <?php $params = require(__DIR__ . '/params.php'); $config = [ 'language' => 'en',

Yii2 Login with database

China☆狼群 提交于 2019-12-14 02:19:31
问题 I have a table in my DB called 'member' where I intend to store username, password and all other related info of a user and I want to use those username/password for login instead yii2's default User.php model. I have been trying for almost a day and modified the Member.php model but can't make it work. Every time I use my custom username/password from db, it says username or password is incorrect. Can anyone please help me out? Thanks in advance. :) FYI, I have no such field in member table

Filtering yii2 grid using a form with related model

自作多情 提交于 2019-12-13 10:27:44
问题 Am using a search model with a search form and i would like to filter a grid view based on the value entered in the form. The form field is of a related table Am actually searching tblpritems and filtering its grid on the column pr_solicitation_id by entering supplier_id as in the tblprsuppliers This is the model relationships In the tblpritems public function getPrSolicitation() { return $this->hasOne(Tblprsolicitations::className(), ['pr_solicitation_id' => 'pr_solicitation_id']); } In the

Records are getting saved even after validation fails in yii2

点点圈 提交于 2019-12-13 08:42:56
问题 I have a model Taluka where we are supposed to select district and enter as many talukas. But the issue is that records are getting saved even if some talukas are empty. Here is my code: public function actionCreate() { $model = new Taluka(); if ($model->load(Yii::$app->request->post()) ) { $talukaslist = $model->talukas; if(is_array($talukaslist)) { foreach($talukaslist as $taluka) { if($taluka == null) { return $this->render('create', [ 'model' => $model, ]); } else if($taluka!=null) {

Testing action with redirect gives uexpectable behavior in yii2

一个人想着一个人 提交于 2019-12-13 05:51:15
问题 I try to test my app with codeception, but all LoginCept.php breaks on this aciton class SiteController extends Controller { public function actionIndex() { $this->redirect('journal'); } } As I can see in the php-buildin-server's logs, after in-app redirect it comes to actual entry point index.php instead of index-test.php [Thu Jun 9 20:54:00 2016] 127.0.0.1:40472 [302]: /index-test.php/login [Thu Jun 9 20:54:00 2016] 127.0.0.1:40496 [302]: /index-test.php << in-app redirect [Thu Jun 9 20:54

How to create floating point validation with two decimals in Yii2?

不羁岁月 提交于 2019-12-13 04:39:11
问题 I have tried creating a validation for a field which stores unit price of a product, I come across validation showing how to check for integer, but I can't found one for floating point number something with a format like 2032.95 in YII2 . Thanks in advance. * After Abilay instructions I tried [['quantity','round_off'],'number','numberPattern'=>'[-+]?[0-9]*.[0-9]+|[0-9]+'], but it shows error in console. 回答1: I think, redefining of numberPattern of NumberValidator class will help in your case.

Search in Related Model using GridView Filter Field

你说的曾经没有我的故事 提交于 2019-12-13 02:48:43
问题 Question: Let's Say i have two tables, Table1 Table2 -authorId -username As of now my sql query on search model looks like this, ->andFilterWhere(['"Table1"."authorId"' => $this->authorName]); It only helps to search and filter using the authorID. Expected Result I would like to search based on the authorname instead of authorId. I faced similar difficulty in reflecting data in view but i was able to fix it with following getter function in base model. public function getAuthorName() { return

ActiveForm without model yii2

房东的猫 提交于 2019-12-12 12:20:48
问题 I want to create ActiveForm without model for just in case something. I did try with dynamicModel but i got some error : use yii\base\DynamicModel; $model = DynamicModel::validateData(compact('KOMENTAR'), [ [['KOMENTAR'], 'string', 'max' => 128], ]); This is the form i want to create <br> <?php $form = ActiveForm::begin([ 'method' => 'post', ]); ?> <?= $form->field($model, 'KOMENTAR')->textarea(['rows' => 6])->label(false) ?> <div class="form-group"> <?= Html::submitButton('POST', ['class' =>