yii2

Swift_IoException Unable to open file for reading yii2

我怕爱的太早我们不能终老 提交于 2019-12-12 03:37:18
问题 I am developing a web application in Yii2. I have attached a file while sending the email. But after attaching the file in email I am facing this error. error Image My code for sending email with attachment goes like this Yii::$app->mailer->compose() ->setFrom('sender email') ->setTo('reciever email') ->setSubject('test') ->setHtmlBody('test') ->attach('path of attachment file') ->send(); I am really facing a big problem please help. 回答1: According to this link http://www.yiiframework.com/doc

How to correctly create function for formatter on PHP in Yii2 Highcharts extension

风格不统一 提交于 2019-12-12 03:32:58
问题 I have to display some special information when my mouse is over a concrete point in a chart that is provided by Highcharts. I am using the Highcharts extension for Yii2. My Code 'tooltip' => [ 'enabled' => true, 'footerFormat' => true, 'formatter' => "js:function() { return 'my special information'; }" ], The data that comes from controller is correct. However there is nothing different - tooltip is still the default What am I doing wrong? 回答1: Sorry. My bad. All is working fine. I just

Yii2 Page not found when calling country/index

怎甘沉沦 提交于 2019-12-12 03:26:16
问题 I was practicing to work with Yii2 based on the tutorial in this link : http://www.yiiframework.com/doc-2.0/guide-start-databases.html I am using Advanced Application These are the files that i have created: frontend/models/Country.php frontend/controllers/CountryController.php frontend/views/country/index.php now when i try to access it using index.php?r=country/index i get 404 not found error . But if i move the actionIndex of CountryController to SiteCountroller and rename it to

How to create a dropdown dependent on another dropdown in yii2?

我的未来我决定 提交于 2019-12-12 03:25:22
问题 I have two api's: 1: returns all the industries, 2: returns all the industry category(based on industry id). I need two dropdowns, one dependent on other. On selecting industry 2nd dropdown should show only relevant categories. Thanks in advance. 回答1: I got it. I have simply used ajax which posts the value from one dropdown and sends the data to an action which returns the data and i am simply putting those values to my other drop down. :) 回答2: <?= $form->field($model, 'industryId')-

How to get dynamic form input values in JavaScript in yii2?

只谈情不闲聊 提交于 2019-12-12 03:24:35
问题 How to get dynamic form input values in JavaScript function? following code working only for zero index input values not for all $this->registerJs( '$(document).ready(function(){ $("‪#‎quotationitem‬-0-unit_price").change(function(){ var unit_value = $("#quotationitem-0-unit_price").val(); var qty_value = $("#quotationitem-0-quantity").val(); var total=Number(unit_value) * Number(qty_value); $("#quotationitem-0-amount").val(total); }); });', \yii\web\View::POS_END); View code as per follows I

Yii2 render two models in one view

情到浓时终转凉″ 提交于 2019-12-12 03:18:31
问题 Yii is the best but I'm have two models , book and author . I need to process two forms for each one in a single view , as I do this in yii2.0 . <?= $this->render('_formBook', array('model' => $model)); ?> <?= $this->render('_formAuthor', array('model' => $model)); ?> 回答1: try this way In your Controller $modelBook = Book::findOne($id); $modelAuthor = Author::findOne($key); return $this->render('_formWithTheTwoForm', 'modelBook' => $modelBook, 'modelAuthor' => $modelAuthor,]); Then in your

Load data to a form from a different model in yii2

*爱你&永不变心* 提交于 2019-12-12 03:13:45
问题 I am creating a form to insert data into table salary . The associated Model is Salary. in the form I have fields s_wageperday,s_conveyanceperday . I have a separate table ratechart where these values are already stored. There's only one row in the table ratechart and it should be.the columns are - wage_per_day, conveyance_per_day . What I want is - when I load the Create form for salary - It should load the data from ratechart table in the respective textfield. What I've done - In

composer works every where except one project

回眸只為那壹抹淺笑 提交于 2019-12-12 03:03:44
问题 I'm beginner in yii2. composer command works in every path in windows 10, but in one of my project's path composer command not works. Actually does nothing at all. It's obviously in this image: I don't know the the reason. My composer.json: { "name": "yiisoft/yii2-app-advanced", "description": "Yii 2 Advanced Project Template", "keywords": ["yii2", "framework", "advanced", "project template"], "homepage": "http://www.yiiframework.com/", "type": "project", "license": "BSD-3-Clause", "support":

Yii2 non-DB (or virtual) attribute isn't populated during massive assignment?

百般思念 提交于 2019-12-12 02:59:12
问题 I've defined a virtual attribute: class ContactForm extends Model { public $name; // is not a DB field I've noticed that it is not populated during massive assignment (after submitting the form, in $model->load($_POST) ). Can it be somehow populated along with DB attributes? Or am I doing something wrong that is not populated however it should be? Thanks! 回答1: Docs: Massive Assignments Like normal models, Active Record instances also enjoy the massive assignment feature. Using this feature,

Dropdown javascript onload

巧了我就是萌 提交于 2019-12-12 02:27:50
问题 I have a dropdown menu, that has a onchange function. Once the function is executed it changes another dropdown menu. I need to make it so it executes the script onload. 1st dropdown: echo $form->field($model, 'company_id')->dropDownList($items_company, ['prompt' => 'Select Company', 'style' => 'width:400px;', 'onchange' => ' $.post("index.php?r=project/lists&id=' . '"+$(this).val(), function( data ) { $( "select#project-client" ).html( data ); console.log("On change"); console.log(data); });