yii2

Yii2 getting the url ID in redirect. in create action

雨燕双飞 提交于 2019-12-13 09:25:18
问题 like I have a view index.php(Gridview)- linked to a Menu Manage Instructor. from there I click on edit for a specific instructor. The URL I get is like: admin/user/update-instructor?id=11 In this page I have multiple tabs, one tab is instructor_schedule , which is again a grid view with add records button on top. I can add records clicking on add record without any issue. My problem is now I want the form page redirect back to the page admin/user/update-instructor?id=11 How I can achieve that

How to pass data from model to a view in yii2

元气小坏坏 提交于 2019-12-13 09:13:55
问题 Here, I'm trying to design a payslip. I want to pass data from model right beside the text. like - <p class="text-center">Pay Slip for the month of </p> The data will be fetched from the model and will be passed right beside "Pay Slip for the month of". Please help. My Controller Action public function actionPrintsalarystatement($id) { //$model = Salary::find()->where(['s_id' => $id]); $model = $this->findModel($id); $searchModel = new SalarySearch(); $dataProvider = $searchModel->search(Yii:

How to solve 500 Error on Yii Db connection

北慕城南 提交于 2019-12-13 09:13:09
问题 I have uploaded yii framework into my server. i'm using string for connecting db is return [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=smargavc_Konnections', 'username' => 'smargavc_Konnect', 'password' => '******', 'charset' => 'utf8', ]; Here, Wheather dont know db is connected or not. When i trying in postman to access the rest call, getting 500 errro 回答1: 500 Error is for CODE error. Not connection error. To check connection you can simply go, print_r(Yii::app(

How to change table users in LoginForm

☆樱花仙子☆ 提交于 2019-12-13 08:46:06
问题 I am asking about LoginForm in Yii2 After I install Yii, I get the default Web with login form inside it. This form will connect to table name "user" Then I modify the default to create new website with different login form. And also I create new table for login name "db_user". I still use the default model named "LoginForm" in commons/model for login. Here is the code <?php namespace common\models; use Yii; use yii\base\Model; /** * Login form */ class LoginForm extends Model { public

Records are getting saved even after validation fails in yii2

点点圈 提交于 2019-12-13 08:42:56
问题 I have a model Taluka where we are supposed to select district and enter as many talukas. But the issue is that records are getting saved even if some talukas are empty. Here is my code: public function actionCreate() { $model = new Taluka(); if ($model->load(Yii::$app->request->post()) ) { $talukaslist = $model->talukas; if(is_array($talukaslist)) { foreach($talukaslist as $taluka) { if($taluka == null) { return $this->render('create', [ 'model' => $model, ]); } else if($taluka!=null) {

ttf and woff files are not using the HSTS

喜你入骨 提交于 2019-12-13 07:57:16
问题 In my project, HSTS is enabled. So if someone is tryig to use the site using the HTTP then it redirects to HTTPS. After the Security scan, it is reported that ttf, woff and woff2 files are ignoring the HSTS. Example 1: On Google Crome if i am trying below URL then it redirects to HTTPS: http://example.com/backend/web/lib/roboto/Roboto-Light.woff2 then it redirects to https://example.com/backend/web/lib/roboto/Roboto-Light.woff2 If i try same thing on Firefox then it just downloads the Roboto

Yii2 webapp on Azure not working

我的梦境 提交于 2019-12-13 07:51:29
问题 I am having a website + services app built on Yii + Yii2 framework respectively. I tried hosting it on Azure http://xxxxxx.azurewebsites.net/ . website which was built on Yii1 was working fine. Services built on Yii2 endpoint returning 404. the services are working in local. Here are the details: Local: Xampp server htdocs/ myapp/ dashboard/ ---> this the website folder (Yii) modules/ v1/ -----> here are my yii2 services and controllers. Now when I try locally with url: http://localhost/myapp

Yii2: Kartik Select2: Initial Value from Model Attribute

随声附和 提交于 2019-12-13 07:25:12
问题 I have a Model who has a column (attribute) that stored a comma separated value of IDs. For Example, Movie has a column "Genre" that includes more than one genre, e.g.: 40,20,1,3 How can I use Select2 widget to show these values separated when 'multiple' => true And how can I save them back into comma-separated value as a string. I want a solution that will allow for quick flexibility. I know you can implode and explode the string but seems too much. Any help appreciated 回答1: If I remember

Swiftmailer Time Exception yii2

▼魔方 西西 提交于 2019-12-13 07:14:45
问题 I have a yii2 project. I make sending email function on it, so I use yii2 swiftmailer. But I have a problem. Sometimes my connection is bad, so when the function is running my application will stop because the time for sending email is just 30 seconds. So, how can I handle the error exception? May be I can use try-catch, but I don't know how to use it for handle time exception. 来源: https://stackoverflow.com/questions/37053798/swiftmailer-time-exception-yii2

Removing a portion of the URL in Yii 2.0

こ雲淡風輕ζ 提交于 2019-12-13 06:49:24
问题 If I enter the URL: http://localhost/third/web/calculator it just works fine. I now want to remove the web portion from the URL. I currently do not have .htaccess. And if I enter http://localhost/third/calculator it shows object not found. I added this .htaccess in the root folder of the project: Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_URI} ^/third/(assets|css) RewriteRule ^assets/(.*)$ web/assets/$1 [L] RewriteRule ^css/(.*)$ web/css/$1 [L] RewriteCond %{REQUEST_URI} !