yii2

PHP: Get Version of ICU

馋奶兔 提交于 2020-03-03 07:34:25
问题 My production site just provides the old ICU version 4.2.1. Since Yii2 requires Version 49.1 or higher I need to make workarounds in PHP. How do I get the nersion number of ICU (libicu) which is used by PHP during runtime. Since I have frequent production updates I need to get the version number dynamically in PHP code, e.g. by $libIcuVersion = ... The version number is shown in phpinfo.php but the output cannot be used in my code. 回答1: This is how Symfony/Intl does it in Symfony\Component

Save multiple models at a time in Yii2

最后都变了- 提交于 2020-02-24 04:31:30
问题 I have two models, Users and Students . I want to insert data into these tables simultaneously. First, I save data into Students model and then into Users models. Now, if data doesn't successfully get inserted into Users model there is already an entry into Students table. What I want is data entries into both model only if data can be successfully saved in both. Now my controller code looks something like this: public function actionCreate() { $model = new Students(); $userModel = new Users(

Save multiple models at a time in Yii2

孤者浪人 提交于 2020-02-24 04:31:06
问题 I have two models, Users and Students . I want to insert data into these tables simultaneously. First, I save data into Students model and then into Users models. Now, if data doesn't successfully get inserted into Users model there is already an entry into Students table. What I want is data entries into both model only if data can be successfully saved in both. Now my controller code looks something like this: public function actionCreate() { $model = new Students(); $userModel = new Users(

Is it possible to hide column Yii2?

三世轮回 提交于 2020-02-23 20:18:37
问题 In Yii2 we have GridView like this: <?= GridView::widget([ 'dataProvider' => $dataProvider, // 'filterModel' => $searchModel, 'layout' => "{items}\n{summary}\n{pager}", 'columns' => [ // ['class' => 'yii\grid\SerialColumn'], 'id', 'size', 'program' => [ 'label' => 'Program', 'value' => function($data) { return Html::a($data->program, ($data->program), ['target' => '_blank']); }, 'format' => 'raw', ], 'version', 'platform', 'license', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> Is it

Yii2 formatter show different date

半世苍凉 提交于 2020-02-06 06:48:27
问题 I want to view time from db and then save it to another db.table in timestamp format, but I've get different time every time I convert it: print_r($sub_datetime['datetime']);echo "<br>"; $temptime = Yii::$app->formatter->asTimestamp($sub_datetime['datetime']); print_r($temptime);echo "<br> "; $temptime2 = Yii::$app->formatter->asDatetime($temptime); print_r($temptime2);echo "<br> "; $temptime3 = Yii::$app->formatter->asTimestamp($temptime2); print_r($temptime3);echo "<br> "; Get: 10-5-2015 10

Yii2 formatter show different date

爱⌒轻易说出口 提交于 2020-02-06 06:46:05
问题 I want to view time from db and then save it to another db.table in timestamp format, but I've get different time every time I convert it: print_r($sub_datetime['datetime']);echo "<br>"; $temptime = Yii::$app->formatter->asTimestamp($sub_datetime['datetime']); print_r($temptime);echo "<br> "; $temptime2 = Yii::$app->formatter->asDatetime($temptime); print_r($temptime2);echo "<br> "; $temptime3 = Yii::$app->formatter->asTimestamp($temptime2); print_r($temptime3);echo "<br> "; Get: 10-5-2015 10

Yii2 formatter show different date

别说谁变了你拦得住时间么 提交于 2020-02-06 06:45:13
问题 I want to view time from db and then save it to another db.table in timestamp format, but I've get different time every time I convert it: print_r($sub_datetime['datetime']);echo "<br>"; $temptime = Yii::$app->formatter->asTimestamp($sub_datetime['datetime']); print_r($temptime);echo "<br> "; $temptime2 = Yii::$app->formatter->asDatetime($temptime); print_r($temptime2);echo "<br> "; $temptime3 = Yii::$app->formatter->asTimestamp($temptime2); print_r($temptime3);echo "<br> "; Get: 10-5-2015 10

How to Use react js with yii2.0

别来无恙 提交于 2020-02-03 08:19:07
问题 I have been doing traditional design using HTMl, CSS on my projects. This time i want to implement reactjs in the design. But i am unable to get clue about how to implement reactjs in my YII2.0 project. 回答1: I've implemented semantic-react in one my project. Works like a charm. You'll need to override bootstrap assets for this to work. Instructions on how to install semantic react are on their official website. Use cdn to make your process more easy. 回答2: you can look on this project, this

Yii2 UrlManager Breaks On Periods

泪湿孤枕 提交于 2020-02-03 01:37:08
问题 I am currently using yii2 urlManager to create a pretty URL. It receives a parameter and then looks up users based on it. Unfortunately, if the parameter contains a period, it won't run at all and redirects to a 404 page. So, mysite.com/me/jbroad works perfectly, but mysite.com/me/j.broad returns a 404 page. Here is my url manager code 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '' => 'site/index', 'me/<id:\w+>' => 'kit/page', 'generate/<id:\w+>' =>

Yii2 making checkbox required doesn't work

旧街凉风 提交于 2020-02-02 11:57:31
问题 This is my form: <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($invite, 'email')->textInput([ 'id' => 'register-email', 'placeholder' => Yii::t('UserModule.views_auth_login', 'email')]); ?> <?php echo $form->field($invite, 'check')->checkbox([ 'id' => 'check', 'uncheck' => null])->label( Yii::t('UserModule.views_auth_login', 'I have read and accept') . ' <a href="#">' . Yii::t('UserModule.views_auth_login', 'Terms & Conditions') . '</a> ' . Yii::t('UserModule.views_auth_login'