yii2

Yii2 mPdf Kartik: Set Height and Width Paper

ⅰ亾dé卋堺 提交于 2019-12-11 04:16:15
问题 How to set custom height and width on PDF format like this: I want set height: 13.6cm and width: 21.2cm if I export to PDF, paper size is always in A4 format , how to make paper size to be 13.6cm (height) and **21.2cm (width) as in the picture above I use mpdf kartik on yii2 .. this my controller code: $pdf = new Pdf([ 'mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => \Yii::getAlias('@webroot') .'/css/pdf/pdf-pfi.css'

How do I create a parameterized database update statement in Yii for an IN() clause?

﹥>﹥吖頭↗ 提交于 2019-12-11 03:55:50
问题 I tried $sql = "update ad_group_keyword set status = :status where google_id not in (:google_id)"; Yii::$app->db->createCommand($sql) ->bindValue(':status', Constants::DELETED) ->bindValue(':google_id', join(',',$googleIds), \PDO::PARAM_INT) ->execute(); but it turned the array of ids into one giant string, despite the PDO::PARAM_INT . I also tried ->bindValue(':google_id', $googleIds) but it gave an 'Array to string conversion' in vendor/yiisoft/yii2/db/Command.php:172 . I ended up using

Has_many relation in DetailView

这一生的挚爱 提交于 2019-12-11 03:54:55
问题 I have the following code in use in gridview and it's working perfectly: ['format' => 'raw', 'label' => 'Categories', 'value' => function ($data) { $string = ''; foreach ($data['fkCategory'] as $cat) { $string .= $cat->category_name . '<br/>'; } return $string; }], This displays all the item's categories on new row within the table cell. However if I want to display something similar in DetailView, it's not working. Detailview gives me an error: Object of class Closure could not be converted

yii2 basic printing a page in pdf

假装没事ソ 提交于 2019-12-11 03:48:06
问题 please help. Hallo all, Am on verge of finishing a project created using yii2 basic. my problem is, I want to print a using with pdf as its output. I have tried yii2 mpdf and yii2-pdf without any success. I want to place the print button in the index.php of a view file. here's is my code snippet located at index view file. <?= Html::a('<i class="fa glyphicon glyphicon-hand-up"></i>Property report',['/propertydetails/report'], [ 'class'=>'btn btn-danger', 'target'=> '_blank', 'data-toggle'=>

Yii2 - validate password (Hash is invalid error)

谁说胖子不能爱 提交于 2019-12-11 03:35:10
问题 I am trying to validate old user password, in order for him to able to change password, but at the moment I am getting Hash is invalid error. This is validation rule: ['password_old', function($attribute){ if(!$this->validatePassword($this->{$attribute})) $this->addError($attribute, 'Please Enter Your Old Password'); }], validatePassword method: public function validatePassword($password){ return Yii::$app->getSecurity()->validatePassword($this->salt . $password, $this->password); } Form used

Problems with Yii2 Rules creation

对着背影说爱祢 提交于 2019-12-11 03:18:57
问题 I have a Yii2 with Yii2 admin, user andAdminLTE installed. My problem is I don't know how to create rules, actually I don't know how to define the Class Name. Where "Classes" should be defined? How can I see which Classes do I have or add Classes? Thanks a lot, 回答1: I don't know what is that module that you use but i know how to define rules for controller.please open a controller for example : mycontroller. when you want create a rule for action in your mycontroller you should use the

How to solve Bad Request (#400) Unable to verify your data submission in yii2?

给你一囗甜甜゛ 提交于 2019-12-11 03:03:24
问题 I have got this error, when submit the form: Bad Request (#400) Unable to verify your data submission. I have got <?= Html::csrfMetaTags() ?> in the layout. I think, that this problems I have, because I use datepicker. Form create with ActiveForm. What I must to do? Here is code of the form: <? $form2 = ActiveForm::begin(['id' => 'user-univer']); echo $form2->field($model2, 'university')->label('Input university name:'); echo $form2->field($model2, 'degree')->label('Input your education

Multiple database connection Yii2 not working

旧时模样 提交于 2019-12-11 03:01:35
问题 Yii::setAlias('@tests', dirname(__DIR__) . '/tests'); $params = require(__DIR__ . '/params.php'); $db = require(__DIR__ . '/db.php'); $dbPusat = require(__DIR__ . '/dbPusat.php'); $dbPaperless = require(__DIR__ . '/dbPaperless.php'); return [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'gii'], 'controllerNamespace' => 'app\commands', 'modules' => [ 'gii' => 'yii\gii\Module', ], 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'log' => [

yii2 sorting in related model

给你一囗甜甜゛ 提交于 2019-12-11 02:58:28
问题 have relation model Shop.php public function getShopAddr() { return $this->hasOne(SprShopAddr::className(), ['id' => 'shop_addr_id']); } model SprShopAddr.php public function getDivision() { return $this->hasOne(SprDivision::className(), ['id' => 'division_id']); } model SprDivision.php public function getShopAddrs() { return $this->hasMany(SprShopAddr::className(), ['division_id' => 'id']); } view index.php <?= GridView::widget([ 'dataProvider' => $dataProvider, //'filterModel' =>

How to set layout for errorhandler dynamically without module

吃可爱长大的小学妹 提交于 2019-12-11 02:19:10
问题 I am new in Yii2, When I started creating a website, i found that you can set ErrorAction in configuration like this 'errorHandler' => [ 'errorAction' => 'site/error', ], That error using layout from layout/main.php. That layout was used when guest visit the page that located in 'view/site'. But when the user log in the view page locate in different folder which is 'view/band' the layout become totally different and using 'layout/BandLayout'. I know that you can change layout dynamically in