yii2

Yii2 get post request value not working

左心房为你撑大大i 提交于 2020-01-05 04:43:10
问题 Why Yii::$app->request->post() not working? Form: <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'parent') ->dropDownList($model->AuthItemDropdown ); ?> <?= $form->field($model, 'child[]') ->dropDownList($model->AuthItemDropdown, ['multiple'=>'multiple'] ); ?> Controller: public function actionCreate(){ $model = new AuthItemChild(); if ($model->load(Yii::$app->request->post())){ $parent = Yii::$app->request->post('parent'); echo $parent; // show nothing $x = Yii::$app->request

Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www)

别说谁变了你拦得住时间么 提交于 2020-01-05 04:28:09
问题 I have a custom members system that I have made: Yii2 Members System. You can refer to that for full details, or install it so you can work with it for this question. I have frontend and backend just as Yii2 provides, with a few modifications to separate the sessions/cookies so that backend works with the Admin model and pulls from an admin table. Similar to old traditional member systems. mainsite is basically a clone of frontend and it's role is to be the main website. What you get when you

how to limit access url view on yii2 by id

a 夏天 提交于 2020-01-05 04:05:17
问题 I am basically a PHP developer & learning Yii2. I am working on web application that has account based login system. Like the way i was doing in PHP web applications, i want to stop another user from accessing the view if he/she is not authenticated. Its like if someone tries to access url(any related URL) externally: www.example.com/permintaanbarang/index.php?r=user/view&id=1 chage to www.example.com/permintaanbarang/index.php?r=user/view&id=2 by another user At that time that person should

Log not working in yii2

半城伤御伤魂 提交于 2020-01-05 03:49:26
问题 i want to put a log in app.log ,My config file 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ 'file' => [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], 'logFile' => '@root/console/runtime/logs/app.log', ], ] ] in controller action public function actionRankCalculation() { $allConest = Contest::find()->where('isActive = 1')->all(); Yii::trace('start calculating average revenue'); $response = []; /** @var Contest $contest */ foreach ($allConest as $contest) {

Textfield Mandatory On basis of radio button selection- Yii2

和自甴很熟 提交于 2020-01-05 02:03:08
问题 I'm having radio button with two value i.e, Individual and Firm. I am looking for one scenario where if radio button having value Firm is selected, then CompanyName textinput should act as mandatory (required) field. And, when radio button having value Individual is selected, Then CompanyName textinput should act as Optional field. I was not getting how to do it. I tried to add addAttribute in CompanyName textinput as mandatory. but it didn't worked as RegisterForm.php (model) is having few

Override Bootstrap CSS in Yii2

蓝咒 提交于 2020-01-04 19:09:07
问题 I have a NavBar and I want to override all the classes that Yii is putting on that widget. After searching inn Google and reading the docs, I found that this code: Yii::$container->set('yii\bootstrap\NavBar', [ 'containerOptions' => [ 'class' => '' ] ]); NavBar::begin([ 'containerOptions' => [ 'class' => 'no-horizontal-padding navbar-content' ] ]); is supposed to override (delete, actually) all classes in the container of my NavBar , but this is not the case. I keep seeing my 2 classes and

Override Bootstrap CSS in Yii2

对着背影说爱祢 提交于 2020-01-04 19:09:02
问题 I have a NavBar and I want to override all the classes that Yii is putting on that widget. After searching inn Google and reading the docs, I found that this code: Yii::$container->set('yii\bootstrap\NavBar', [ 'containerOptions' => [ 'class' => '' ] ]); NavBar::begin([ 'containerOptions' => [ 'class' => 'no-horizontal-padding navbar-content' ] ]); is supposed to override (delete, actually) all classes in the container of my NavBar , but this is not the case. I keep seeing my 2 classes and

yii2 create translated URLs

旧街凉风 提交于 2020-01-04 15:26:47
问题 I need to create user-friendly URLs which are translated, yet point to the same controller as the others for a language. Example: /en/myCar/100 -> /de/meinAuto/100 -> /fr/monVoiture/100 I tried using routes but couldn't find a way to call the controller depending on a translated URL. Any hints where I should start? 回答1: It can't be done easily with built in functionality, but someone had the same need and wrote a package specifically for this: yii2-localeurls. I think that might be what you

Yii2: Config params vs. const/define

六月ゝ 毕业季﹏ 提交于 2020-01-04 02:45:16
问题 When should I use what? I have the option to define constants in the index.php entry script file like it is recommended in Yii2 guide: constants. Or I could use the params in the configuration - explained in YII2 guide: params. Both are per application and not really global. Currently, it seems to me that params are a bit less comfortable if I want to combine values like this: define('SOME_URL', 'http://some.url'); define('SOME_SPECIALIZED_URL', SOME_URL . '/specialized'); Besides, accessing

REST API for yii2, the authenticator (HttpBearerAuth) is not working on server

試著忘記壹切 提交于 2020-01-04 02:12:11
问题 I've just created a project for working with REST API (using yii2 framework). All issues of REST API is working really cool on localhost. But when bringing the project on server (also the same database is taken by), the authorization is not available. Now I'm using "yii\filters\auth\HttpBearerAuth" Inside the model "implements IdentityInterface", there's finding-token function "findIdentityByAccessToken" that's so simple, the "validateAuthKey" function is returning always true; see below: