yii2

Autocomplete in yii2

烂漫一生 提交于 2019-12-21 02:19:31
问题 In Yii2 I want one of my input field to be autocomplete when user starts to type.Below is my code which uses Jui Autocomplete . <?php $items= ArrayHelper::map(Company::find()->all(), 'c_id', 'name'); echo AutoComplete::widget([ 'model' => $model, 'attribute' => 'company', 'clientOptions' => [ 'source' => $items, ], ]);?> This is not working.When i printed my array, i got like Array ( [1] => abc [2] => xyz [4] => pqr ) I got it working when i manually set like $items=['abc','xyz','pqr']; The

Nginnx config for Yii 2 Advanced App Template

て烟熏妆下的殇ゞ 提交于 2019-12-21 02:16:08
问题 I would like to configure the Nginx web-server in such a way that: Requests to the /index.php URI should be handled by public_html/frontend/web/index.php Requests to the /admin/index.php URI should be handled by public_html/backend/web/index.php Advice please where I'm wrong. Here is my config: server { listen 80; server_name yii2.lo; server_tokens off; client_max_body_size 128M; charset utf-8; access_log /var/log/nginx/yii2-access.log main buffer=50k; error_log /var/log/nginx/yii2-error.log

Yii2 fresh install: vendor/bower/jquery/dist path is wrong

≯℡__Kan透↙ 提交于 2019-12-21 01:57:52
问题 I just installed yii2 (advanced) using composer. I've setup nginx, etc. But it doesn't work: Invalid Parameter – yii\base\InvalidParamException The file or directory to be published does not exist: /srv/www/site/vendor/bower/jquery/dist In the folder 'vendor/bower' there is the only subfolder 'bower-assets' with 'jquery', etc in it. But no jquery in vendor/bower. How to solve this issue? 回答1: Please, refer the installation guide. It seems that you are missing asset plugin: composer global

Yii2 fresh install: vendor/bower/jquery/dist path is wrong

て烟熏妆下的殇ゞ 提交于 2019-12-21 01:57:34
问题 I just installed yii2 (advanced) using composer. I've setup nginx, etc. But it doesn't work: Invalid Parameter – yii\base\InvalidParamException The file or directory to be published does not exist: /srv/www/site/vendor/bower/jquery/dist In the folder 'vendor/bower' there is the only subfolder 'bower-assets' with 'jquery', etc in it. But no jquery in vendor/bower. How to solve this issue? 回答1: Please, refer the installation guide. It seems that you are missing asset plugin: composer global

Loading core scripts such as jQuery in Yii 2

℡╲_俬逩灬. 提交于 2019-12-21 01:57:22
问题 I've been having a hard time trying to figure out how to load jQuery or other CORE scripts in Yii 2 . In Yii 1 it seemed this was the way: <?php Yii::app()->clientScript->registerCoreScript("jquery"); ?> In Yii 2, $app is a property of Yii, not a method, so the above naturally doesn't work, but changing it to: <?php Yii::$app->clientScript->registerCoreScript("jquery"); ?> produces this error: Getting unknown property: yii\web\Application::clientScript I couldn't find any documentation for

Yii2: Jui Auto Complete Widget how to?

筅森魡賤 提交于 2019-12-20 20:26:13
问题 I am trying to use yii2 Jui autocomplete widget. I have this code which is showing the auto-complete date correctly, but I am not able to save the data. $data=ArrayHelper::map(State::find()->all(), 'id', 'state_name' ); $data=array_merge($data); And then echo 'State' .'<br>'; echo AutoComplete::widget([ 'model'=>$model, 'attribute' => 'state_id', 'clientOptions' => [ 'source' => $data, ], ]); Any solution will be greatly appreciated. Thanks. 回答1: Ok I found the solution, it goes like this:

Yii2: How exactly does user authentication works? [closed]

旧时模样 提交于 2019-12-20 20:03:26
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I don't understand Authentication in Yii2 . In Yii 1 there was an identity class where we need to work with the authentication() method and call CWebUser::login() to achieve our goals. What are the main processes of authentication in Yii 2 ? And how does it work exactly? Can you

Yii2: How exactly does user authentication works? [closed]

♀尐吖头ヾ 提交于 2019-12-20 20:03:05
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I don't understand Authentication in Yii2 . In Yii 1 there was an identity class where we need to work with the authentication() method and call CWebUser::login() to achieve our goals. What are the main processes of authentication in Yii 2 ? And how does it work exactly? Can you

Hide label for input field

℡╲_俬逩灬. 提交于 2019-12-20 16:21:47
问题 I am trying to hide the label for a specific field in _form.php without success. I have tried couple of variation like, but none is working: <?= $form->field($model, 'sample_text')->textArea('label'=>false) ?> and alternate code: <?= $form->field($model, 'sample_text')->textArea('label'=>'') ?> What is the right approach to hide a label? 回答1: Ok, I found the solution. <?= $form->field($model, 'sample_text')->textArea()->label(false) ?> 回答2: Or you can modify template value for particular

Yii2 : Search in Gridview using Pjax POST Method with pagination

家住魔仙堡 提交于 2019-12-20 15:20:14
问题 I am beginner to yii2 & trying to search fields in Gridview using Pjax on search button. I have done this with GET method but I want to do this by using POST method. Then how can I do this with Yii2 Pjax(post method) with pagination? Here is my code : _details.php : <?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\widgets\Pjax; use kartik\depdrop\DepDrop; $js = <<<JS // get the form id and set the event $('#bank-details-form').on('beforeSubmit', function(e) { var form = $(this)