yii2-advanced-app

Yii2 form submit button must be clicked two times for action. How to prevent this?

巧了我就是萌 提交于 2019-12-10 20:48:33
问题 yii2 submit button needs to be clicked two times in form I have a problem where I need to check more than one submit buttons in the controller. It works but I need to click submit buttons two times. In controller : switch(\Yii::$app->request->post('submit')) { case 'submit_1' : //my code break; case 'submit_2' : //my code In view <?= Html::submitButton('NEXT', ['name' => 'submit', 'value' => 'submit_2','class'=>'btn btn-primary pull-right']) ?> <?= Html::submitButton('PREVIOUS', ['name' =>

Cannot use yii\base\Object as Object because 'Object' is a special class name yii2 advance

拥有回忆 提交于 2019-12-10 19:12:42
问题 I just bougth a stronger pc, installed composer and wanted to continue my project on it but when I use gii it give me this error. How can I fix it ? Why am I getting it ? Thank you. 回答1: solved. since 2.0.13, the class name Object is invalid since PHP 7.2, use [[BaseObject]] instead. So in the vendor/yiisoft/yii2-gii/CodeFile.php just had to change Object to BaseObject. 回答2: solved. since 2.0.13, the class name Object is invalid in PHP 7.2, //Replace //class User extends \yii\base\Object

how multiple row delete using checkbox in yii2

别说谁变了你拦得住时间么 提交于 2019-12-10 18:35:02
问题 How can I use in GridView delete selected object,in Yii 2 Framework such as following image: [enter image description here][2] 回答1: Try this <?=Html::beginForm(['controller/bulk'],'post');?> <?=Html::dropDownList('action','',[''=>'Mark selected as: ','c'=>'Confirmed','nc'=>'No Confirmed'],['class'=>'dropdown',])?> <?=Html::submitButton('Send', ['class' => 'btn btn-info',]);?> <?=GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ ['class' => 'yii\grid\CheckboxColumn'], 'id', ],

Yii2 > How to store html output of a _form view into a string variable

不打扰是莪最后的温柔 提交于 2019-12-10 15:56:37
问题 I want to store the rendered html output of a form view which uses ActiveForm and Html Helper into a variable within my Controller. I've tried storing result of a renderPartial directly to a variable, which did not work: $htmlform = Yii::$app->controller->renderPartial('_form', ['model' => $model]); I've also tried using output buffering to echo the output into a variable, but I could not store the output: ob_start(); echo Yii::$app->controller->renderPartial('_form', ['model' => $model]);

Yii2 How to pass the model instance to the main layout?

喜夏-厌秋 提交于 2019-12-10 13:40:00
问题 I have a change password bootstrap modal which will get triggered when the user clicks on the Change password navBar menu. I have included the modal in the footer. But how can I pass the ChangePassword model instance to the footer layout file? Can beforeRender Or EVENT_BEFORE_RENDER be used? If yes, How? As suggested, I have put the following code in common/config/bootstrap.php: yii\base\Event::on(yii\base\View::className(), yii\base\View::EVENT_BEFORE_RENDER, function() {

How to configure global uploadPath and uploadUrl in Yii2?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 13:23:35
问题 I want to configure Global Params in Yii2. For example this: This will store the server path for all your file uploads. Yii::$app->params['uploadPath'] = Yii::$app->basePath . '/uploads/'; This will store the Url pointing to server location for your file uploads. Yii::$app->params['uploadUrl'] = Yii::$app->urlManager->baseUrl . '/uploads/'; When I set params like this: 'uploadPath' => Yii::$app->basePath . '/uploads/', 'uploadUrl' => Yii::$app->urlManager->baseUrl . '/uploads/', I am getting

How to put custom HTML into Yii2 GridView header?

孤者浪人 提交于 2019-12-10 13:19:22
问题 There's this <abbr></abbr> tag in bootstrap that will automatically shows popup of the abbreviated word. I want to insert this tag to a certain header in the gridview with attribute name act . Here is my code so far. [ 'attribute'=>'act', 'format'=>'raw', 'label'=>'<abbr title="Area Coordinating Team">ACT</abbr>', 'value'=>function($model){ return '<span class="fa fa-thumbs-up text-green"></span>'; } ], but the output literally shows the whole <abbr title="Area Coordinating Team">ACT</abbr>

Yii2 - Getting unknown property: yii\console\Application::user

╄→гoц情女王★ 提交于 2019-12-09 16:43:25
问题 I am trying to run a console controller from the terminal, but i am getting this errors every time Error: Getting unknown property: yii\console\Application::user here is the controller class TestController extends \yii\console\Controller { public function actionIndex() { echo 'this is console action'; } } and this is the concole config return [ 'id' => 'app-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'console\controllers', 'modules' => [],

What the idea behind environment folders in Yii2 and how to use it?

試著忘記壹切 提交于 2019-12-09 14:29:23
问题 I've read through Yii2 documentation several times. I also googled and I couldn't find anything useful yet. The problem is I do not understand the concept of the environment folders. Please let me explain: I can use branches in Git (for dev, staging and production) *-local.conf files are ignored by Git and they won't be pushed to staging or production in anyway Why I have to duplicate all my controllers, views and other files in environment/dev & environment/prod ? In what folders I actually

Using Yii1 and Yii2 in the same project

两盒软妹~` 提交于 2019-12-09 12:04:45
问题 I had a project in Yii1.x and now I am using Yii2 for the same projects Project hierarchy is something like this Project1(yii1)/all yii files + project2(yii2) project2(yii2)/frontend + /common + /backend Now I want to know if is it possible to use project2/common/models in project1/protected/controllers How can I achieve this task? Thank you 回答1: I wouldn't recommend doing it, instead it's better to completely rewrite old application in Yii2. But in case of partial migrating, please read this