yii2

swiftmailer and Yii2 not working 1 out of 10 time

我是研究僧i 提交于 2019-12-13 19:40:48
问题 I have a background process sending email to me when specific event occur. It's working most of the time (9 out of 10), but sometime I get the following error message : PHP Warning 'yii\base\ErrorException' with message 'fwrite(): SSL: An established connection was aborted by the software in your host machine.' in E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php:232 Stack trace: #0 [internal function]: yii\base\ErrorHandler->handleError

application configuration file path of yii2

99封情书 提交于 2019-12-13 19:14:51
问题 I installed yii2 and then added gii to yii2 from this link. return [ 'bootstrap' => ['gii'], 'modules' => [ 'gii' => 'yii\gii\Module', // ... ], // ... ]; I want to plce this code in application configuration file where it is located? 回答1: Application configuration file reside in: project_name/config/web.php if (YII_ENV_DEV) { $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class'=>'yii\gii\Module', 'allowedIPs'=>['127.0.0.1','192.168.1.*'], ]; 回答2: You will find a file web.php

Yii2: how to add model and model id in mPDF

北城以北 提交于 2019-12-13 19:02:14
问题 I need to generate pdf from my view, Im using kartik mPDF, Controller : public function actionInvoicesPrint() { $pdf = new Pdf([ 'mode' => Pdf::MODE_CORE, // leaner size using standard fonts 'content' => $this->renderPartial('view', ['model' => $model, 'mode' => Pdf::MODE_CORE, 'format'=> Pdf::FORMAT_A4, 'orientation'=> Pdf::ORIENT_POTRAIT, 'destination'=> Pdf::DEST_BROWSER]), ]); return $pdf->render(); } Getting error Undefined variable: model . I tried as shown above but getting same error.

Yii2: What is the correct way to define relationships among multiple tables?

元气小坏坏 提交于 2019-12-13 18:53:33
问题 In a controller I have the following code: public function actionView($id) { $query = new Query; $query->select('*') ->from('table_1 t1') ->innerJoin('table_2 t2', 't2.t1_id = t1.id') ->innerJoin('table_3 t3', 't2.t3_id = t3.id') ->innerJoin('table_4 t4', 't3.t4_id = t4.id') ->andWhere('t1.id = ' . $id); $rows = $query->all(); return $this->render('view', [ 'model' => $this->findModel($id), 'rows' => $rows, ]); } See the db schema: https://github.com/AntoninSlejska/yii-test/blob/master

Yii2 : validate if at least one checkbox is selected

只谈情不闲聊 提交于 2019-12-13 18:24:46
问题 I have multiple Music releases for a user for which he wants to create a promo, on the promo create form we have all the releases listed and I am using a form model for creating the promo where I define all rules for my several inputs in the promo form model. I want to check if at-least one release is selected by the user when saving the form but it is not working as the checkboxes are created dynamically. my form code for that field foreach ($releaseInfo as $releases) { if (!is_null(

Redirecting to backend via htaccess Yii2

好久不见. 提交于 2019-12-13 17:42:35
问题 I am trying to redirect my url to the admin ( backend ) part on domain/admin via htaccess. Still not very familiar with .htaccess and what I did so far is Main .htaccess in the root directory: #adding the charset AddDefaultCharset utf-8 #hide the structure Options -Indexes #if dir is symbol, follow it Options FollowSymlinks #engine on RewriteEngine #if there is admin word in the URI go on the next rule RewriteCond %{REQUEST_URI} ^/admin$ #load the backend index file, append the group to the

yii2 dependent autocomplete widget

谁说我不能喝 提交于 2019-12-13 17:19:45
问题 I have two fields in a form: <?= $form->field($model, 'bill_country')->widget(AutoComplete::className(), ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => $country_name]])->label('Country') ?> <?= $form->field($model, 'bill_zip')->widget(AutoComplete::className(), ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => '/city/list/+id']])->label('Zip') ?> Based on the selection of the first block, I want to change the 'source' of the second one. +id

What does this Yii error #8192 mean?

≯℡__Kan透↙ 提交于 2019-12-13 17:11:29
问题 I get this error on Heroku for a Yii2 app. I searched the source code and can't even find error 8192. Error (#8192) An internal server error occurred. Other pages work, but just this one page doesn't work. There is no error message in heroku logs . There is no runtime/logs/app.log file. 回答1: It was because I was accessing a non-static class method statically. It worked in development. I had to turn on debugging in production (which was a big hassle by itself) to find out. 回答2: What you should

How to change export sheet/doc properties in Yii2 krajee grid export?

試著忘記壹切 提交于 2019-12-13 16:14:30
问题 We have used yii2 krajee export for exporting grid data. How can we modify default title, description , lastmodifiedby? echo ExportMenu::widget([ 'dataProvider' => $dataProvider, 'columns' => $gridColumns, 'target' => ExportMenu::TARGET_SELF, 'exportConfig' => [ ExportMenu::FORMAT_PDF => false, ], 'filename' => 'export-list_' . date('Y-m-d_H-i-s'), ]); 回答1: Try This : Here is a example of CSV. You can do like wise for others also. use yii\helpers\Html; use kartik\grid\GridView; use kartik

yii2:- how can i manage angularjs post request in yii2

江枫思渺然 提交于 2019-12-13 15:38:31
问题 I am trying to send post request from angular controller to yii front end controller. Here is my controller.js 'use strict'; define(['angular', 'd3', 'd3Cloud', 'services'], function (angular, d3) { /* Controllers */ return angular.module('oc.controllers', ['oc.services']) .controller('InitCtrl', ['$scope','$http', function ($scope,$http) { $scope.loginFun = function() { var formData = {username:$scope.txtUserName, pwd:$scope.txtPassword}; $http.post("http://localhost/yii2-angular-seed-master