yii2

Yii2: how to use component in ActiveController default action

烈酒焚心 提交于 2019-12-11 09:55:13
问题 As docs say: [[yii\rest\IndexAction|index]]: list resources page by page response has view: curl -i -H "Accept:application/json" "http://192.168.100.5/index.php/tweets" HTTP/1.1 200 OK Date: Wed, 30 Mar 2016 12:10:07 GMT Server: Apache/2.4.7 (Ubuntu) X-Powered-By: PHP/5.5.9-1ubuntu4.14 X-Pagination-Total-Count: 450 X-Pagination-Page-Count: 23 X-Pagination-Current-Page: 1 X-Pagination-Per-Page: 20 Link: <http://192.168.100.5/tweets?page=1>; rel=self, <http://192.168.100.5/tweets?page=2>; rel

Display results while joining tables in yii2

六眼飞鱼酱① 提交于 2019-12-11 09:45:25
问题 I am joining two tables tbl_complain_type and tbl_section.The sql for that tables are CREATE TABLE IF NOT EXISTS `tbl_complain_type` ( `id` int(9) NOT NULL, `section_id` varchar(250) NOT NULL, `complains` varchar(250) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ; -- -------------------------------------------------------- -- -- Table structure for table `tbl_section` -- CREATE TABLE IF NOT EXISTS `tbl_section` ( `id` int(9) NOT NULL, `section` varchar(250) CHARACTER SET

Yii2 gridview - modal only display when click on first row

本秂侑毒 提交于 2019-12-11 08:54:48
问题 I am using kartik\grid\GridView and kartik\grid\ExpandRowColumn to display summary info. On expandRowColumn, I have another gridview to list details info. This part is working fine. Under expandRowColumn gridview I am using modal to view data for column Details. Click modal on first expandRowColumn working fine but got error on other expandRowColumn row. There is no error message but modal is not displaying error_image Gridview on expandRowColumn $gridColumns = [ ['class' => 'yii\grid

after make or change password User dont login in Yii2

微笑、不失礼 提交于 2019-12-11 08:54:01
问题 after make or edit password User i have login error 'Incorrect username or password' in Yii2 login with user 'admin' is work ( i make admin user with actionCreate1) auth_key: kYm0pvYAXY4IzuV7eYgGgtjSqoxxMNUL password: $2y$13$QqsbMW3ErXwWOPad3abDYOPzh5XLwuEvQKBhZGEEDoT0Av5l0bE2S but i make user or edit password , in login page i have error: 'Incorrect username or password' i think problem from beforeSave in Model USER User Table: id int auth_key text username text password text actionCreate:

Yii2: How add a symbol before and after an input field

大城市里の小女人 提交于 2019-12-11 08:51:29
问题 How can I add a symbol before and after of an input text? Just like the image attach. My code: <?= $form->field($model_product, 'percent')->textInput(['class'=>'smallInputFormInline'])->label('Percent',['class'=>'labelModalFormInline']) ?> <?= $form->field($model_product, 'percent_all')->textInput(['class'=>'smallInputFormInline'])->label('Percent All',['class'=>'labelModalFormInline']) ?> <?= $form->field($model_product, 'amount')->textInput(['class'=>'smallInputFormInline'])->label('Amount'

Action not found after AJAX request

血红的双手。 提交于 2019-12-11 08:31:52
问题 Before for submitting I want to send the request to an action. But in return I get 404 not found . The action is obviously there. Also got it in the filters of the controller. JS: $('#home-contact').on('beforeSubmit', function(){ $.ajax({ method: 'post', url: '/site/send-contact', data: new FormData($(this))[0], success: function(data){ console.log(data) } }) return false }) Controller filters: 'access' => [ 'class' => AccessControl::className(), 'only' => ['logout', 'signup', 'send-contact']

Get data from textbox and pass to Controller in yii2

≯℡__Kan透↙ 提交于 2019-12-11 08:07:34
问题 Itis the same question as Pass data from a form to a controller in yii2. I want to get data from user in 3fields and pass it to a controller action. I'm trying to do this by javascript but it seems that the javascript function is not being called. Nothing happens when I click on the button. No error in the console as well. I'm attaching the code of 3 fields,button and javascript below. index2.php <?php use yii\helpers\Html; //use yii\grid\GridView; use kartik\grid\GridView; use kartik\export

Yii2 hasOne relation link to multiple table

走远了吗. 提交于 2019-12-11 08:03:55
问题 I have 4 tables are agent, vendor, operator and ticket. A ticket is belong to only one of agent, vendor or operator. I designed ticket table have two fields: org_type and org_id In Ticket model class, I want to build 3 function getAgent, getVendor, getOperator use hasOne relation of Yii2 Solution 1: public function getAgent() { if ($this->org != Organization::ORGANIZATION_TYPE__AGENT) return null; return $this->hasOne(Agent::class, ['id' => 'org_id']); } will be failed because I can't use

Filter data with kartik Select2 widget in gridview

☆樱花仙子☆ 提交于 2019-12-11 08:00:35
问题 I've added a kartik select2 widget on top of the index page. My intention is to filter 2 gridview simultaneously in the same page with the same selected value. I have written the jquery and the json result(alert) is showing fine. But cannot get the result in the gridview. Please help. Please let me know if there's any better approach in this regard. My index.php file - <?php use yii\helpers\Html; use yii\grid\GridView; use kartik\select2\Select2; use yii\helpers\ArrayHelper; use frontend

after auto logout how to redirect the control to login page in yii2?

六眼飞鱼酱① 提交于 2019-12-11 07:44:14
问题 I am using below code to auto logout after some time interval 'session' => [ 'timeout' => 10, ], 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => false, 'authTimeout' => 10, ], It logged out successfully but did not redirect to login page how to do that? 回答1: You can use behaviors for actions. public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'only' => ['index', 'logout','view','create','update','delete'], 'rules' => [ [