Issue
This is my simple index.php file
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$this->title = 'Qwert';
?>
<?php $variable=1; //that variable
$f=ActiveForm::begin() ?>
<?php
if($variable==1){
echo Html::submitButton('First Button',['name'=>'b','value'=>1])."<br/>";
}else{
echo Html::submitButton('Second Button',['name'=>'b','value'=>2]);}
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;} ?>
<?php ActiveForm::end() ?>
So I want to after click First button it appears Second. Where is my mistake?
Solution
In my Controller, I have to add return.
if(Yii::$app->request->post('b')==='1' ) {$variable=2; return $this->render('index');}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;return $this->render('index');}
Answered By - STepHan
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.