yii2-advanced-app

Yii2 params access within local config file in common directory

笑着哭i 提交于 2019-11-28 03:43:37
问题 I'm using Yii2 advanced template, I want to access params.php in main-local.php file, I called this ways: main-local.php: 'mailer' => [ 'class' => 'myClass', 'apikey' => \Yii::$app->params['mandrill_api_key'], 'viewPath' => '@common/mail', ], and I have stored this mandrill_api_key in params.php params.php: <?php return [ 'adminEmail' => 'admin@example.com', 'supportEmail' => 'support@example.com', 'user.passwordResetTokenExpire' => 3600, 'mandrill_api_key' => 'mykey' ]; I'm getting this

Get response in JSON format in Yii2

时光总嘲笑我的痴心妄想 提交于 2019-11-28 02:47:40
问题 I'm trying to convert and array of response into JSON format. I have tried all the answers that were posted on SO and other websites like web1,web2 adding header('Content-Type: application/json') and then echo json_encode($data,JSON_PRETTY_PRINT); But I'm always getting the output in text format. Can some one help me in solving this. Helpers Class: public static function renderJSON($data) { header('Content-Type: application/json'); echo json_encode($data,JSON_PRETTY_PRINT); } My Controller:

wbraganca yii2 dynamic form date picker issue?

时光毁灭记忆、已成空白 提交于 2019-11-28 02:01:56
问题 I am using wbraganca dynamic form. In my form one field need date picker,so i use jui date picker like below <?= $form->field($model, "[{$i}]DOB")->widget(DatePicker::classname(), [ 'language' => 'en', 'options' => ['class'=>'cust-form-control dob','placeholder'=>'Date of birth','autocomplete'=>'off','readOnly'=>true,'aria-label' => 'Date of Birth'], 'clientOptions'=>[ 'changeMonth'=>true, 'changeYear'=> true, 'yearRange'=> "1925:+0", 'dateFormat' => 'dd/mm/yy', 'maxDate' => "-1D", ], ])-

Yii2. Access to higher level folder

时间秒杀一切 提交于 2019-11-27 09:52:35
Simple question. I use Yii2 advanced template. In apache I have DocumentRoot "{$path}/www/yii-application1/frontend/web" . How can I access /www/yii-application1/uploads in order to show image to user? Following code does not work: <?php echo Html::img('../../uploads/ring.jpg') ?> It works with DocumentRoot "{$path}/www/yii-application1/" . But in this case an index page of website looks like domain.com/frontend/web . But I need just domain.com . Step : 1 First create .htaccess file in here yii-application1/.htaccess Options +FollowSymlinks RewriteEngine On # deal with backend first

LIMIT is not working in ActiveDataProvider

守給你的承諾、 提交于 2019-11-27 09:26:19
Hi guys i am using following code and the limit doesnt work, but if i see the command than it shows limit in that but when i pass the query to ActiveDataProvider it fetch all the records $data= User::find()->where(['category_id'=> 5])->orderBy(['rand()' => SORT_DESC])->limit(4); $command = $data->createCommand(); $data2 = $command->queryAll();// This works fine and fetch only 4 data $dataProvider = new ActiveDataProvider([ 'query' => $data, ]); // But this displays all data without limit What is wrong i am doing here??? Here is what happens when preparing models in yii\data\ActiveDataProvider

Yii2. Access to higher level folder

断了今生、忘了曾经 提交于 2019-11-26 14:57:46
问题 Simple question. I use Yii2 advanced template. In apache I have DocumentRoot "{$path}/www/yii-application1/frontend/web" . How can I access /www/yii-application1/uploads in order to show image to user? Following code does not work: <?php echo Html::img('../../uploads/ring.jpg') ?> It works with DocumentRoot "{$path}/www/yii-application1/" . But in this case an index page of website looks like domain.com/frontend/web . But I need just domain.com . 回答1: Step : 1 First create .htaccess file in

LIMIT is not working in ActiveDataProvider

妖精的绣舞 提交于 2019-11-26 14:35:39
问题 Hi guys i am using following code and the limit doesnt work, but if i see the command than it shows limit in that but when i pass the query to ActiveDataProvider it fetch all the records $data= User::find()->where(['category_id'=> 5])->orderBy(['rand()' => SORT_DESC])->limit(4); $command = $data->createCommand(); $data2 = $command->queryAll();// This works fine and fetch only 4 data $dataProvider = new ActiveDataProvider([ 'query' => $data, ]); // But this displays all data without limit What