yii2

Yii2 Not allowed to load local resource (Image)

眉间皱痕 提交于 2019-12-25 18:48:07
问题 i got this error in inspect element under console Not allowed to load local resource: file:///C:/xampp/htdocs/Yii2System/backend/web/data/cust_images/user_1.jpg in view file: <div class="col-md-12 text-center"> <?= Html::img($info->getUserPhoto($info->user_photo), ['alt'=>'No Image', 'class'=>'img-circle']); ?> </div> in controller: public function actionUserPhoto($uid) { $model = $this->findModel($uid); $info = UserInfo::findOne($model->user_info_id); $info->scenario = 'photo-upload'; $old

Yii2: finfo_file(C:\xampp\tmp\php29C.tmp): failed to open stream: No such file or directory

99封情书 提交于 2019-12-25 18:47:16
问题 Getting error finfo_file(C:\xampp\tmp\php29C.tmp): failed to open stream: No such file or directory while uploading multiple files. tried inserting $model->save(); before saveAs() but then it upload only one file not all files, also not getting path in database for each file which is getting uploaded. Controller: public function actionCreate() { $model = new RoomTypes(); if ($model->load(Yii::$app->request->post())) { $imageName = $model->room_type; $model->file = UploadedFile::getInstances(

change the priority of selected attribute in listbox

我与影子孤独终老i 提交于 2019-12-25 17:55:08
问题 Following is the example code : IN CONTROLLER foreach($UserTypesArray as $key => $value) { $model->allowed_users[$key] = ['selected' => 'selected']; } $model->htmlOptions = array('multiple' => 'true', 'options' => $model->allowed_users); IN VIEW $form->field($model, 'user_type_id[]')->listBox($model->all_users , $model->htmlOptions); OK here we go! I have searched a lot on "how to make list box with pre selected values from the database" Two things happened 1) I ended up writing the above

Yii2.0 yiic command not working

梦想的初衷 提交于 2019-12-25 17:43:32
问题 Hi I am new to Yii framework development. Yiic webapp not working, even when you run yiic on the commandline I was following a tutorial on-line but I got stuck because the yiic command is not recognised and I also noticed that the framework folder is not there. I download Yii 2.0 archive from the Yii home website and extracted it to my Webroot folder. Thanks in advance. 回答1: I recommend you install composer and follow the instructions here: http://www.yiiframework.com/doc-2.0/guide-start

How to differentiate categories in highcharts drilldown?

江枫思渺然 提交于 2019-12-25 16:44:10
问题 I want to make the chart like the picture below. I made the chart below by typing data manually. Picture 1 But, I want to take data from database, but I don't know how to categorize the xAxis. I have codes like this: controller $faculty = (new \yii\db\Query()) ->select(['Faculty']) ->from('facultyin2011') ->limit(10) ->column(); $age1 = (new \yii\db\Query()) ->select(['lessthan25']) ->from('facultyin2011') ->limit(10) ->column(); $age1 = array_map('floatval', $age1); foreach ($age1 as $key =>

How to differentiate categories in highcharts drilldown?

Deadly 提交于 2019-12-25 16:43:21
问题 I want to make the chart like the picture below. I made the chart below by typing data manually. Picture 1 But, I want to take data from database, but I don't know how to categorize the xAxis. I have codes like this: controller $faculty = (new \yii\db\Query()) ->select(['Faculty']) ->from('facultyin2011') ->limit(10) ->column(); $age1 = (new \yii\db\Query()) ->select(['lessthan25']) ->from('facultyin2011') ->limit(10) ->column(); $age1 = array_map('floatval', $age1); foreach ($age1 as $key =>

Yii2: How to map a CSV string in an attribute to CheckboxList in a form?

偶尔善良 提交于 2019-12-25 15:54:43
问题 I have a model with an attribute that holds a CSV string. (The model is actually an ActiveRecord object but I guess this is not important. Correct me if I'm wrong.) /** * @property string $colors Can be something like "red" or "red,green,blue" or "" */ class Product extends Model { } And I have a form in which I'd like to display this attribute as a checkboxList so that the user can select the possible values with simple clicks instead of typing into a textInput. Theoretically, it should look

(Yii2) Variable not working from post

空扰寡人 提交于 2019-12-25 12:45:19
问题 This is my simple index.php file <?php use yii\helpers\Html; use yii\widgets\ActiveForm; $this->title = 'Qwert'; ?> <?php $variable=1; //that variable $f=ActiveForm::begin() ?> <?php if($variable==1){ echo Html::submitButton('First Button',['name'=>'b','value'=>1])."<br/>"; }else{ echo Html::submitButton('Second Button',['name'=>'b','value'=>2]);} if(Yii::$app->request->post('b')==='1' ) {$variable=2;} if(Yii::$app->request->post('b')==='2' ) {$variable=1;} ?> <?php ActiveForm::end() ?> So I

Class 'dosamigos\ckeditor\CKEditor' not found

瘦欲@ 提交于 2019-12-25 09:28:33
问题 I am working on a project in Yii2 where I need to integrate CKEditor . I used this to install it: composer require 2amigos/yii2-ckeditor-widget It downloads the library files under /vendor directory. When I copied the files from local to server and used this: use dosamigos\ckeditor\CKEditor; <?= $form->field($userSurveyConfig, 'survey_email_body')->widget(CKEditor::className(), ['options' => ['rows' => 6],'preset' => 'basic']) ?> When I run the page, this error pops up: > Class 'dosamigos

Changing yii2 password by checking the current password with the entered password

淺唱寂寞╮ 提交于 2019-12-25 09:15:01
问题 Am trying to change password in yii2 advanced app but it always fails I have a model which finds the entered password and checks it against the stored password and if it is true it returns true but if false it should fail. This is model part This is what sets a user password public function setPassword($password) { $this->password = Yii::$app->security->generatePasswordHash($password); } This is what is used to compare the two passwords public function findPasswords($attribute, $params){