yii2

Passing multi-dimensional array within Yii2 validation rules?

徘徊边缘 提交于 2019-12-14 02:35:12
问题 When you are using Yii2's validation rules within a model, for example: [['foo','bar'], 'integer], Obviously ['foo','bar'] is an array, which I know you can use. But can do pass a multi-dimensional array like this: $this->numbers = [1,2,3]; [['foo','bar','numbers'], 'integer] Will Yii2 accept this and check the correct data or will it test the value and return an error because numbers is an array? 回答1: You need merge arrays for work rules [ArrayHelper::merge(['foo','bar'], $this-

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

Repost/ asking again. Change event in Kartik's bootstrap-slider extension for Yii2

穿精又带淫゛_ 提交于 2019-12-14 00:05:33
问题 I asked that question today and the user gave me best answer, but it seems that its not working. Maybe its all because i use not raw Bootstrap-slider.js but Kartik's extension. So here is what i do: <div class="col-md-4"> <input type="text" class="form-control" id="test" placeholder="50000"> <?php echo Slider::widget([ 'name'=> 'test-bi', 'sliderColor'=> Slider::TYPE_GREY, 'pluginEvents' => [ 'slide' => "function(slideEvt) { $('#test').val(slideEvt.value); }", ], 'pluginOptions' => [ 'min'=

Remove index.php from url after removing web folder from frontend and backend in yii2

折月煮酒 提交于 2019-12-13 23:53:29
问题 I want to remove index.php from url. I put .htaccess in the root and wrote the following lines in common/config/main-local.php . But every url is redirected to backend. My .htaccess file: RewriteEngine on # If a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise forward it to index.php RewriteRule . index.php My common/config/main-local.php file: 'urlManager' => [ 'class' => 'yii\web\UrlManager', // Disable index.php

Yii2 autologin doesn't work

佐手、 提交于 2019-12-13 23:23:39
问题 I try to realize the autologin feature in yii2. So I've enabled autologin in configuration: 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, 'loginUrl' => ['account/login', 'account', 'account/index'], ], Also I've added rememberMe field in form configuration public function scenarios() { return [ 'login' => ['username','password','rememberMe'], 'activate' => ['password','passwordrepeat'], 'register' => ['username', 'mail'], 'setup' => ['username', 'password',

azurewebsites/IIS 7 internal server when connecting to remote MySQL db using Yii 2 framework

对着背影说爱祢 提交于 2019-12-13 22:15:47
问题 I have a Azure WebApp + Services written in Yii and Yii 2 respectively. The database is MySQL db from ClearDB . i am hosting it on using the empty Php app . Reference: https://blogs.msdn.microsoft.com/azureossds/2015/07/23/migrate-yii-framework-application-to-azure-web-app/ The webapp is working fine. In services when trying to connect to the ClearDB MySQL its working fine in XAMPP. When use the same code in IIS 7 in my local (to simulate azurewebsites) i am receiving: i am getting error 500

Mailchimp Oauth2 sample app troubleshooting

限于喜欢 提交于 2019-12-13 22:04:38
问题 I keep getting the following error when I try to use the Mailchimp OAUTH2 sample app (PHP). For your reference, here's their github repo: https://github.com/mailchimp/OAuth2-sample-apps However, my client id and client secret are correct (have copied and pasted them multiple times). Complete Failure!: redirect_uri_mismatch This likely means that you have entered a bad client_id or client_secret or you are being awesome and checking to see this failure occur. Try Again? If it helps, I'm using

Yii2 URL manager rules and forms with GET method

送分小仙女□ 提交于 2019-12-13 20:02:49
问题 I have a global search form that submits to search action of a controller: <?=Html::beginForm(['/feqh/search'], 'get', ['class' => 'navbar-form navbar-left', 'role' => 'search', 'id' => 'searchForm']);?> <div class="form-group has-feedback Right"> <input id="q" type="text" class="form-control" placeholder="<?=yii::t('app','Search');?>" name="q" value="<?= Html::encode(\Yii::$app->getRequest()->getQueryParam('q',""));?>" /> <i class="form-control-feedback glyphicon glyphicon-search"></i> </div

Validate unique value from database in Yii2

ⅰ亾dé卋堺 提交于 2019-12-13 19:50:51
问题 I am trying to validate email value as unique value. Doing it like this. [['HRMS_candidateEmail'],'unique'], But it is not working, inserted statement use yii\validators\UniqueValidator; , following this link Model <?php namespace app\models; use Yii; use yii\validators\UniqueValidator; class Candidate extends \yii\db\ActiveRecord { /** * @inheritdoc */ public static function tableName() { return 'HRMS_candidate'; } /** * @inheritdoc */ public function rules() { return [ [['HRMS