yii2

Yii2 theme baseurl

落花浮王杯 提交于 2019-12-24 07:38:38
问题 I'm trying to echo Yii2 theme base url using this official link. <?php $theme = $this->theme; echo $theme->baseUrl; // line 119 ?> but it return me this error : PHP Notice – yii\base\ErrorException Trying to get property of non-object in E:\wamp\www\yii2-app\frontend\views\site\index.php at line 119 Why this error? is it not possible to get Yii2 theme base url? 回答1: seems that you component is not properly defined .. be sure you have a theme defined in you components section eg: return [

Changing sql query to yii2 format

僤鯓⒐⒋嵵緔 提交于 2019-12-24 07:13:03
问题 Am using dataProvider and i would like to convert a query in sql so that it follows the dataProvider way of representing data This is the raw sql SELECT tblpritems.PRlineID , tblpritems.Tracking_Code , tblpritems.Description , tblpritems.Quantity , tblpritems.Unit_Price , tblpritems.Extended_price , tblpritems.PRID , tblpritems.pr_solicitation_id , tblpritems.date_item_received , tblpritems.Quantity_received , tblpritems.Remarks_on_receipt , tblpritems.Received_by FROM prts.tblpritems INNER

Yii2 basic gridview just header and values

安稳与你 提交于 2019-12-24 06:49:48
问题 I would like to show data of a joined query... (Controller): $znw_a = Znw::find()->withA()->where(['znw.id' => $zg_id])->one(); ... return $this->render('create', [ ... 'znw_a' => $znw_a, ...like a very basic gridview, without pager, summary, etc, only the pure header with the data. The main idea is to show it like if it was a detailview simply transposed, so that I see data from left to right instead of top to bottom, so like a simple Excel table for example. Is there such a simple widget

yii2 checkboxList custom class

你。 提交于 2019-12-24 05:34:13
问题 Here is the sample code from Yii2 checkboxList, I want to add custom class for each Item in checkboxList but I don't know how and where can I add that! Could you please help me please .. $list = [0 => 'PHP', 1 => 'MySQL', 2 => 'Javascript']; $list2 = [0,2]; echo Html::checkboxList('CuisineId',$list2,$list,array('class' => 'test' )); Thanks in advance. 回答1: If you want to add the same class, you should use itemOptions : echo Html::checkboxList('CuisineId', $list2, $list, ['itemOptions'=>[

Yii2 Ajax .post to controller from dropdownList of view and some action upon receiving data

你离开我真会死。 提交于 2019-12-24 04:47:09
问题 I have a DropDown list. I've written the code but it's not working. Please help me to fix it: echo $form->field($model, 'Adrop')->dropDownList( [ '' => 'Please Choose', '1' => 'item 1', '2' => 'item 2' ], [ 'onchange' => '$.post(Yii::$app->urlManager->createUrl . "users/A_action"), function(data) { $("#test_div").html(data) }' ] ); Also I want to send selected data, and don't know where to write it. In the Controller I have this action public function actionA_action() { $data = "TTT"; return

Yii2 : Gridview with fixed first column

夙愿已清 提交于 2019-12-24 04:24:04
问题 Can someone help me to implement a Gridview (Yii2) where the first column (NAME) was always visible and the others I could scroll horizontally to the side. My customers asked for an Excel-like interface where they could view and filter various customer information (various products marked YES or NO). At first, I have this example as a reference: REF 1 from bootsnip .scrolling table { table-layout: inherit; *margin-left: -100px; /*ie7*/ } .scrolling td, th { vertical-align: top; padding: 10px;

Error deploying yii2-starter-kit Yii2 installation

左心房为你撑大大i 提交于 2019-12-24 03:52:20
问题 I'm trying to deploy this Yii2 installation (https://github.com/trntv/yii2-starter-kit/blob/master/docs/installation.md#configure-your-web-server) but I'm having problems. I think problems are related with this configuration step: "Configure your web server". I've the webpage running here: http://vector5.raspctl.com/yii2-starter-kit/frontend/web/ But no one of the options works. For example, "Connect" option (http://vector5.raspctl.com/yii2-starter-kit/frontend/web/user/sign-in/login) I can't

Error deploying yii2-starter-kit Yii2 installation

一曲冷凌霜 提交于 2019-12-24 03:52:17
问题 I'm trying to deploy this Yii2 installation (https://github.com/trntv/yii2-starter-kit/blob/master/docs/installation.md#configure-your-web-server) but I'm having problems. I think problems are related with this configuration step: "Configure your web server". I've the webpage running here: http://vector5.raspctl.com/yii2-starter-kit/frontend/web/ But no one of the options works. For example, "Connect" option (http://vector5.raspctl.com/yii2-starter-kit/frontend/web/user/sign-in/login) I can't

How to allow guest access to some actions in Yii2 Controller?

試著忘記壹切 提交于 2019-12-24 03:28:05
问题 I'd like to know how to configure my controller to allow some actions to be executed as a guest and be able to show the view for that guest in Yii2. I've tried this rule in my behaviour 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => ['create','update'], 'allow' => true, 'ips' => ['127.0.0.1'], ] ], ] Edit: This is the config I tried : 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'actions' => ['create', 'update'], 'roles

How to set attributes as unsafe in RESTful Yii2?

泄露秘密 提交于 2019-12-24 02:52:43
问题 I have a controller in Yii2 that extends ActiveController to be RESTful and I can update it OK using the PUT method. However I would like to set some attributes as unsafe as I don't want them to be updatable. Reading some different examples I thought I would be able to do something like this in the model's rules: [['first_name','last_name','!password'], 'safe', 'on' => 'update'], However this doesn't prevent password being updated. So then I found the scenarios() method and thought this