yii2

How can I get the selected data/item rows in CheckboxColumn Gridview - Yii2

爱⌒轻易说出口 提交于 2019-12-24 02:52:25
问题 I have a problem on getting all the selected values/data Yii2 Gridview using checkboxColumn. I can only get one of the value in the grid using this code: 'class' => 'yii\grid\CheckboxColumn', 'checkboxOptions' => function($model, $key, $index, $widget) { return ['value' => $model['item_id'] ]; }, Need some suggestions on how can I get all the values in the grid... Here is my Code Code snippet Controller/View: Controller: public function actionBulk(){ $action=Yii::$app->request->post('action')

Login on production server doesn't work

眉间皱痕 提交于 2019-12-24 02:23:58
问题 On local server it works, but when I try to login on production server I get this message: PHP Notice – yii\base\ErrorException Array to string conversion 1. in /var/www/html/vendor/yiisoft/yii2/web/User.php at line 240 2. in /var/www/html/vendor/yiisoft/yii2/web/User.php – yii\base\ErrorHandler::handleError(8, 'Array to string conversion', '/var/www/html/vendor/yiisoft/yii...', 240, ...) at line 240 3. in /var/www/html/common/models/LoginForm.php – yii\web\User::login(common\models\User,

yii2 unique validation not working

做~自己de王妃 提交于 2019-12-24 02:18:13
问题 Yii2 Unique Validation not working for combination of employee id and company id Below are my model code. public function rules() { return [ [['company_id', 'role_id'], 'required'], [['company_id', 'role_id', 'status'], 'integer'], [['employee_id'], 'string', 'max' => 15], [['report_to'], 'string', 'max' => 16], [['id',],'safe'], ['employee_id', 'unique', 'targetAttribute' => ['company_id', 'employee_id'], 'message' => 'The combination of Company ID and Employee ID has already been taken.'] /

Yii2 disable highlighting menu item

亡梦爱人 提交于 2019-12-24 01:33:27
问题 My main.php code <?php NavBar::begin([ 'brandLabel' => 'Styl-dekoracje.pl', 'brandUrl' => Yii::$app->homeUrl, 'options' => [ 'class' => 'navbar-inverse navbar-fixed-top', ], ]); echo Nav::widget([ 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'Orders', 'url' => ['/order']], Yii::$app->user->isGuest ? ['label' => 'Login', 'url' => ['/site/login']] : ['label' => 'Logout (' . Yii::$app->user->identity->username . ')',

how to populate gridview from ajax call using Yii2

百般思念 提交于 2019-12-24 01:17:54
问题 In my project, I have created a search box. when I type something and click the button "get info" I get all information in console window using ajax call. now I want to populate this data in yii2 gridview. data will different at every runtime. I want to give this data to $dataprovider of gridview is it possible?? here is code- CompaniesController.php public function actionCompanyinfo(){ $text_in_search = $_GET['text_in_search']; $left_items_cat = ltrim($_GET['left_items_cat']); if($left_items

How to filter date field in yii2

旧街凉风 提交于 2019-12-24 01:15:58
问题 I want to filter Date column like 3 months ago, 6 months ago, 1 year ago. I have created a dropdown in search field of gridview as given below. [ 'attribute' => 'modified', 'value' => 'name', 'filter' => array("ID1" => "Before Three months", "ID2" => "Before six months", "ID" => "Before Twelve months",), ], and in modelsearch I want to search like... if (($this->modified) == "ID1"){ $query->andFilterWhere(['between', $this->modified, 'today', '3monthsago']); } but I can't understand what

Yii2 url manager don't parse urls with get parameter

只谈情不闲聊 提交于 2019-12-24 00:51:22
问题 I've created a module named catalogue with, for the moment, two actions in the default controller: actionIndex actionLineProducts in the index view I have some link which run the line-product's action, the url was the result of: Url::to(['line-products', 'line' => $line->name]) my goal is to obtain a link like catalogue/{line-name} where line-name is the parameter I send to action LineProducts. My urlManager configurations are: 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' =>

Validating unique email using DynamicFormWidget - Yii2

邮差的信 提交于 2019-12-24 00:34:20
问题 I am using DynamicFormWidget for multiple input fields like: first_name , last_name , email & mobile_no . And, I don't want user to type the existing email . Means, email should be unique. It is working when I am not using DynamicFormWidget . Actually, I don't know how to validate unique email in multiple input forms using Yii2. addmembers.php (View) <?php use yii\helpers\Html; use yii\widgets\ActiveForm; use wbraganca\dynamicform\DynamicFormWidget; ?> <?php DynamicFormWidget::begin([

How to add captcha in Yii-2 application?

断了今生、忘了曾经 提交于 2019-12-23 22:58:32
问题 I'm trying to add the captcha to the login form. My environment: Yii 2 php 5.4.45 TS IIS 10.0 Windows 10 In login.php , LoginForm.php and SiteController.php I added the following (shown only the relevant parts): backend\views\site\login.php: use yii\captcha\Captcha; ... <?= $form->field($model, 'captcha')->widget(Captcha::className()) ?> ... common\models\LoginForm.php: ... public $captcha; ... public function rules() { return [ ... [['username', 'password', 'captcha'], 'required'], ['captcha

Yii2-Use SqlDataProvider with GridView and enable Gridview Filter for search

孤街醉人 提交于 2019-12-23 22:22:09
问题 I am working on yii2 . I have a custom view in which I have placed to views DetailView and GridView . Below is my controller code public function actionViewcreated($id)// passed the id of my model which is created in the previous step { $model=$this->findModel($id); // this will find my model/record based on the id $sub_div = $model->sub_div; $meter_type = $model->meter_type; $query = "SELECT DISTINCT m.`id` AS meter_id, ins.`meter_msn` AS Meter_Serial_Number, ins.`meter_type` AS Meter_Type,