yii2

Join tables using model in Yii2

南楼画角 提交于 2020-01-06 09:05:20
问题 this is table1 id1 Name ------------ 1 value1 2 value2 this is table2 id2 Name id1 --------------------- 1 value1 2 2 value2 1 this is table3 id3 Name id2 --------------------- 1 value1 2 2 value2 1 this is table4 id4 Name id3 --------------------- 1 value1 2 2 value2 1 I Want to join above 4 tables in Yii2 with model select * from table1 left join table2 on table2.id2 = table1.id1 left join table3 on table2.id3 = table1.id2 left join table4 on table2.id4 = table1.id3 回答1: 1. Use Yii2

Bootstrap not working inside pdf

六月ゝ 毕业季﹏ 提交于 2020-01-06 08:29:13
问题 This is my controller code public function actionPrint_death_certificate1() { $this->layout = 'certificate'; $html = $this->render('test'); require_once(Yii::$app->basePath . "/../vendor/mpdf/mpdf/mpdf.php"); $mpdf=new mPDF(); $mpdf->WriteHTML($html); $mpdf->Output(); } My view <div class="container"> <div class="row"> <div class="col-md-6"> Heading1 </div> <div class="col-md-6"> Heading2 </div> </div> </div> Now i get a pdf with heading1 and heading2 in two different lines. Bootstrap is not

Yii2 - Update data by switch toogle using Ajax/Pjax in GridView

耗尽温柔 提交于 2020-01-06 07:58:13
问题 I want to update my data in GridView using Switch Toogle without refresh the current page. Here is the image: So I want to update the attribute status using the toogle switch like the image above. Here is my code: index.php <?= GridView::widget([ 'dataProvider' => $dataProvider, //'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], //'alumni_id', 'tahun_lulus', 'file_excel', [ 'attribute' => 'status', 'format' => 'raw', 'value' => function($data){ if($data-

Yii2: How to change font-family of Select2 widget

爱⌒轻易说出口 提交于 2020-01-06 07:57:11
问题 I have a select2 widget and I need to change its font-family. <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'], 'class' => 'form-control', ]) ?> Bootstrap doesn't have a class to change it so I think I need to change its style. 回答1: you can add style to it like follows: <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'],

Yii2: How to change font-family of Select2 widget

痞子三分冷 提交于 2020-01-06 07:56:10
问题 I have a select2 widget and I need to change its font-family. <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'], 'class' => 'form-control', ]) ?> Bootstrap doesn't have a class to change it so I think I need to change its style. 回答1: you can add style to it like follows: <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'],

Yii2 how to save received JSON data into database

风流意气都作罢 提交于 2020-01-06 06:48:04
问题 I have created an API which returns me an array of data in json Array ( [0] => stdClass Object ( [MSN] => 002999001207 [PingDateTime] => 2018-05-04T16:33:27 [PingValue] => 22 ) [1] => stdClass Object ( [MSN] => 002999001195 [PingDateTime] => 2018-05-04T16:34:11 [PingValue] => 21 ) [2] => stdClass Object ( [MSN] => 002999001180 [PingDateTime] => 2018-05-04T14:42:40 [PingValue] => 20 ) [3] => stdClass Object ( [MSN] => 002999001157 [PingDateTime] => 2018-05-04T14:42:52 [PingValue] => 30 ) [4] =

Yii2 how to save received JSON data into database

ⅰ亾dé卋堺 提交于 2020-01-06 06:48:00
问题 I have created an API which returns me an array of data in json Array ( [0] => stdClass Object ( [MSN] => 002999001207 [PingDateTime] => 2018-05-04T16:33:27 [PingValue] => 22 ) [1] => stdClass Object ( [MSN] => 002999001195 [PingDateTime] => 2018-05-04T16:34:11 [PingValue] => 21 ) [2] => stdClass Object ( [MSN] => 002999001180 [PingDateTime] => 2018-05-04T14:42:40 [PingValue] => 20 ) [3] => stdClass Object ( [MSN] => 002999001157 [PingDateTime] => 2018-05-04T14:42:52 [PingValue] => 30 ) [4] =

Yii2 ArrayDataProvider does not show already paginated data

╄→гoц情女王★ 提交于 2020-01-06 05:33:24
问题 I have an issue with ArrayDataProvider object that Yii2 provides. I have a huge API call that returns more than 7k items (this is a problem because obtaining all items takes a long time). I realized that I can tell the API to paginate for me so I was trying to implement the already paginated data into an ArrayDataProvider but only works in page 1, when I ask for page 2 I see that API returns the next 50 items but in my view the GridView object does not show anything. An example: $dataProvider

How do I add a Label Hint to Kartik DetailView

家住魔仙堡 提交于 2020-01-06 02:55:06
问题 I'm using Kartik DetailView and would like to have a hint appear when the user hovers over the label (like the GII forms). I've tried the following, but it does not work. $attributes = [ [ 'attribute'=>'name', 'inputWidth'=>'50%', ], [ 'attribute'=>'round_precision', 'hint' => 'Specify the number of decimal digits after the decimal to round to. Use a negative value to round the integer part of the number to the number of digits before the decimal. A value of 1 will round 1.855 to 1.7, and a

Swiftmailer in Yii2 - Unable to send email

╄→гoц情女王★ 提交于 2020-01-06 02:43:28
问题 I'm using basic Yii2 template and Swiftmailer to send email.. Here is my code for config/web.php : 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport // for the mailer to send real emails. 'useFileTransport'=>'false', 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.gmail.com', 'username' => 'myemail@gmail.com', 'password' => 'password', 'port' => '587',