yii2

PHP separate string

偶尔善良 提交于 2020-08-20 15:48:26
问题 I have a string that contains 128.82 . I want to split/separate them in 100 and 28.82 . var_dump(substr($kwh,0,3)); die(); It gives me 128 . How can I separate the 100 and 28.82 ? Any help would be highly appreciated Note: I am setting this because I have defined slabs. 1-100 , 101-150 , and so on. So I need to set them according to the slabs. The slabs may differ as it could be 1-50 , 51-100 , 100-150 , and so on. so I have to divide/split 128.82 like 50 for 1-50 , 50 for 51-100 and then 28

Yii2- insert value to text input field on button click via jquery

会有一股神秘感。 提交于 2020-08-10 18:12:36
问题 I am working on yii2 . I have created a dynamic form. I have some fields in it. <div class="pull-right"> <button type="button" id="addBtn" class="add-item btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button> <button type="button" id="remBtn" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> </div> <div class="row"> <div class="col-sm-3"> <?= $form->field($modelTariffSlabs, "[{$i}]slab_name")->textInput(['readonly'=>true,'value'=>

Yii2- insert value to text input field on button click via jquery

孤者浪人 提交于 2020-08-10 18:12:13
问题 I am working on yii2 . I have created a dynamic form. I have some fields in it. <div class="pull-right"> <button type="button" id="addBtn" class="add-item btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button> <button type="button" id="remBtn" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> </div> <div class="row"> <div class="col-sm-3"> <?= $form->field($modelTariffSlabs, "[{$i}]slab_name")->textInput(['readonly'=>true,'value'=>

YII 2 Get Site URL

无人久伴 提交于 2020-08-06 07:50:30
问题 My Application is deployed on localhost/upload. I am using following code to generate relative URL. Url::to('@web/my_controller/action'); // it returns /upload/my_controller/action But, I need full URL like this instead: http://localhost/upload/my_controller/action. Am I missing something? 回答1: You should simply use a route : Url::to(['my_controller/action']); And if you want an absolute base url : Url::to(['my_controller/action'], true); Read more : http://www.yiiframework.com/doc-2.0/yii

How to upload image to digital Ocean Spaces using AWS SDK for Yii2?

耗尽温柔 提交于 2020-08-05 06:45:11
问题 Since Digital Ocean Spaces API is compatible with AWS SDK, how to upload images to Digital Ocean Spaces programmatically using AWS SDK for Yii2? Here my details Good, we have the following data: 1. endpoint: fra1.digitaloceanspaces.com 2. bucket name: dev-abc 3. api key: xxxxxxxxxxxxx and api secret: xxxxxxx 4. The url that you need to use to deliver assets is https://dev-abc I have tried with this code whis is not working $uploader = new FileUpload(FileUpload::S_S3, [ 'version' => 'latest',

How to upload image to digital Ocean Spaces using AWS SDK for Yii2?

不想你离开。 提交于 2020-08-05 06:43:49
问题 Since Digital Ocean Spaces API is compatible with AWS SDK, how to upload images to Digital Ocean Spaces programmatically using AWS SDK for Yii2? Here my details Good, we have the following data: 1. endpoint: fra1.digitaloceanspaces.com 2. bucket name: dev-abc 3. api key: xxxxxxxxxxxxx and api secret: xxxxxxx 4. The url that you need to use to deliver assets is https://dev-abc I have tried with this code whis is not working $uploader = new FileUpload(FileUpload::S_S3, [ 'version' => 'latest',

Jquery add 1 against each text input in yii2 dynamic form

霸气de小男生 提交于 2020-08-05 06:39:12
问题 The bounty expires in 5 hours . Answers to this question are eligible for a +100 reputation bounty. Faisal is looking for an answer from a reputable source . I already have added one question related to it. But there is a little change this time. I have a readonly text input with a default value 1 . <?= $form->field($modelTariffSlabs, "[{$i}]slab_start")->textInput(['readonly'=>true,'value'=>'1','maxlength' => 10,"class"=>"form-control js-slab-start"]) ?> Also, I have another text input which

Jquery add 1 against each text input in yii2 dynamic form

我怕爱的太早我们不能终老 提交于 2020-08-05 06:39:09
问题 The bounty expires in 5 hours . Answers to this question are eligible for a +100 reputation bounty. Faisal is looking for an answer from a reputable source . I already have added one question related to it. But there is a little change this time. I have a readonly text input with a default value 1 . <?= $form->field($modelTariffSlabs, "[{$i}]slab_start")->textInput(['readonly'=>true,'value'=>'1','maxlength' => 10,"class"=>"form-control js-slab-start"]) ?> Also, I have another text input which

trigger active form validation manually before submit

有些话、适合烂在心里 提交于 2020-08-02 07:34:20
问题 is it possible to call the active form validation programmatically via javascript? I need to call the validation procedure before doing some ajax operations. 回答1: Guess I'm a bit late with a reply here but I just had the same question and the solution by soju did not work for me either. So I looked a bit deeper into the JS-code of ActiveForm and found that it appears to monitor the status of each field in a variable and if the field is "untouched" the validation isn't triggered, unless

How to properly view table data using if statement in yii2

蓝咒 提交于 2020-07-31 04:11:40
问题 I am working on yii2 . I have a page in which I have created a table. Now I want to put some data into it via my database query using if....else statement. <tbody style="text-align: center; line-height: 12px"> <?php $bd = $dataProvider2->getModels(); foreach ($bd as $a) { $strt =$a['slab_start']; $end = $a['slab_end']; $rate = $a['rate']; if ($end !='') { echo "<tr> <td>".print_r($strt).".".print_r('-').".".print_r($end)."</td> <td>".print_r($rate)."</td> </tr>"; } else { echo "<tr> <td>"