yii2

Sliding image using yii2

守給你的承諾、 提交于 2019-12-13 05:48:45
问题 I want to make image slideshow in yii2, but unfortunatelly the image can't change. AppAsset: class AppAsset extends AssetBundle { public $css = [ // 'css/site.css', 'css/animate.css', 'css/font-awesome.min.css', 'css/main.css', 'css/prettyPhoto.css', ]; public $js = [ 'js/main.js', 'js/html5shiv.js', 'js/jquery.isotope.min.js', 'js/jquery.prettyPhoto.js', 'js/main.js', 'js/respond.min.js', ]; public $depends = [ 'yii\web\YiiAsset', 'yii\bootstrap\BootstrapAsset', 'yii\bootstrap

Yii2: Call to a member function saveAs() on null while uploading multiple file

雨燕双飞 提交于 2019-12-13 05:31:52
问题 While uploading multiple file getting this error: When I put [['file'], 'file', 'maxFiles' => 4], in model getting following error: Call to a member function saveAs() on null But when I put this [['file'], 'file'], in model, its uploading. Why am I getting error? View: <?php echo $form->field($model,'file[]')->label(false)->widget(FileInput::classname(), [ 'options'=>['accept'=>'image/*', 'multiple'=>true], 'pluginOptions'=>['allowedFileExtensions'=>['jpg','gif','png'] ]]); ?> Controller:

How to set css at time of PDF creation in yii2?

大城市里の小女人 提交于 2019-12-13 04:43:54
问题 Pdf fuction* This function is call from ajax after getting data from this function it's call anothe file here I am display data which is coming from data base.That file all css part in style tag using then as it is style tag prind in pdf as a text and if this all css file include in css folder then pdf is not create in proper format public function actionInvoicespacking(){ $pdf = Yii::$app->pdf; $modelShipment = Shipment::find()->orderBy('ship_id DESC')->one(); if(count($modelShipment) == 0)

How to pass php variable to PluginEvent config Slider Kartik extension for Yii2

心已入冬 提交于 2019-12-13 04:14:15
问题 I use Slider Kartik extension for Yii2. There is PluginEvent options, that i want to config to my needs. So here is my code: <?php echo Slider::widget([ 'name'=>'rating_1', 'value'=>7, 'sliderColor'=>Slider::TYPE_GREY, 'pluginEvents' => [ 'slide' => "function(slideEvt) { $('#testVal. ').text(slideEvt.value); }", ], ]); ?> <span>Current Slider Value: <span id="testVal">3</span></span> But in my HTML layout i used models attribute like: $value['strategy_title'] Is there is the way to put my

component is not getting loaded in yii2 basic

大城市里の小女人 提交于 2019-12-13 04:12:05
问题 I am using yii2 basic template. I am trying create RBAC DB using database migration in yii2, I have created few tables successfully and while I am creating RBAC tables I have got different function as show below: protected function getAuthManager() { $authManager = Yii::$app->getAuthManager(); if (!$authManager instanceof DbManager) { throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.'); } return $authManager; } This

Yii2 Dynamic form wbraganca copy value to cloned field [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-13 04:02:07
问题 This question already has an answer here : wbraganca/yii2-dynamicform values copied to cloned field on edit, but not on create (1 answer) Closed last year . I am using wbraganca dynamic form in my Yii2 project, where I want to copy the values entered in the first set of fields to the set of fields in the cloned div. What I understand, that jQuery copies the values to the cloned field by default. When going through the dynamicform.js of the extension, I find code which I think overrides the

How to make dropdown in Yii2 from one record

白昼怎懂夜的黑 提交于 2019-12-13 03:57:40
问题 Is it possible to make dropdown in Yii2 from two column in one row table like this: I want dropdown list like this: 回答1: You haven't provided any details of the model you are using for the dropdown so I will demonstrate the example with Phone model and the fields are id , phone , area_code , just for the sake of understanding. This is the data for phone table: +----+-------------+-----------+ | id | phone | area_code | +----+-------------+-----------+ | 1 | 03214442021 | 021 | | 2 |

Yii2 .htaccess redirect to backend part

安稳与你 提交于 2019-12-13 03:50:54
问题 I have installed Yii2 advanced app and what i am trying to do now is to redirect this url htpp://site/admin to the backend ( admin ) side. What i tried so far is: AddDefaultCharset utf-8 Options +FollowSymLinks IndexIgnore */* RewriteEngine on # Make the backend accessible via url: http://site/admin RewriteRule ^admin$ $admin.php [L] # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php

Yii2 ActiveForm validation error on Kartik's FileInput widget

不问归期 提交于 2019-12-13 03:49:15
问题 I have an ActiveForm with Kartik's FileInput widget. It is a type of Edit Form. I am fetching db data in it along with images. Case 1 - If Image is already added, it is showing large-image field as required whenever I click on update button. Case 2 - If I Choose new image, it is working fine. How can I set some value for FileInput for existing images to make it not empty/valid. I want some solution for case1. Each time its asking for new image to update any changes. Please help me to fix this

Timezone in Yii2

落爺英雄遲暮 提交于 2019-12-13 03:49:11
问题 My computer time zone 'Asia/Tashkent' . And I set Yii2 time zone to 'Asia/Tashkent' too in config. But Yii2 is still displaying time incorrectly. I am wondering what I have missed? $time = date("Y-m-d H:i:s", time()); echo $time; // 2018-03-07 14:10:57 echo Yii::$app->formatter->asTime($time, 'medium'); // 7:10:57 PM echo Yii::$app->formatter->asDate($time, 'medium'); // Mar 7, 2018 echo date_default_timezone_get(); // Asia/Tashkent 回答1: If you are giving asTime() string date formatter