emil_pgc
(Emil Thushara)
July 2, 2011, 11:33am
1
I want to redirect to a page once by form is submitted
now i am redirecting it to home page.
if($model->validate())
{
$model->save();
$this->redirect(Yii::app()->homeUrl);
return;
}
instead of that i need to redirect it to a page created by me.
I just know that we can do it like this
$this->redirect(array('controller/action'));
So for redirecting is it necessary to create a action for that in controller?
If so wat should i write inside that action??
softark
(Softark)
July 2, 2011, 1:32pm
2
Do you mean that you want to show the page that will display the newly created record ?
If so, and if you already have an action to display an individual record in the same controller … I guess you should have it … then the following will do:
$this->redirect(array('view','id'=>$model->id));
where ‘view’ stands for the action, ‘id’ for the parameter for it and ‘$model->id’ for PK.
You may want to change them according to your existing code.
emil_pgc
(Emil Thushara)
July 2, 2011, 1:34pm
3
softark:
Do you mean that you want to show the page that will display the newly created record ?
If so, and if you already have an action to display an individual record in the same controller … I guess you should have it … then the following will do:
$this->redirect(array('view','id'=>$model->id));
where ‘view’ stands for the action, ‘id’ for the parameter for it and ‘$model->id’ for PK.
You may want to change them according to your existing code.
No i know that to display… i want to display a new page written order placed successfully.
So i just want to know what action should i write in the controller
softark
(Softark)
July 2, 2011, 1:58pm
4
Ah, OK. I think I’ve got it.
You want a new page to show "Thank you for your order. Your order is …".
Yes, then you have to write a new action in the controller and a corresponding view script for it.
How about making use of "actionView" method and "view.php" script as the skeleton for your new page?
emil_pgc
(Emil Thushara)
July 2, 2011, 2:22pm
5
softark:
Ah, OK. I think I’ve got it.
You want a new page to show "Thank you for your order. Your order is …".
Yes, then you have to write a new action in the controller and a corresponding view script for it.
How about making use of "actionView" method and "view.php" script as the skeleton for your new page?
Ok… But how will i pass that msg instead of the model list being getting displayed?
Can you just tell me how to redirect to about us page?
using that method i will redirect to the new page i created.
softark
(Softark)
July 2, 2011, 2:34pm
6
The fixed messages like "Thank you very much" should be written with HTML code in the view script,
and the variables like item name, order amount, price, … etc should be retrieved from the database record that has been created. So you can pass just the id of the newly added record.
emil_pgc
(Emil Thushara)
July 2, 2011, 3:17pm
7
softark:
The fixed messages like "Thank you very much" should be written with HTML code in the view script,
and the variables like item name, order amount, price, … etc should be retrieved from the database record that has been created. So you can pass just the id of the newly added record.
I have created a page like this…
<?php
$this->pageTitle=Yii::app()->name . ' -Confirmation';
$this->breadcrumbs=array(
'Confirmation',
);
?>
<p>Successfully placed your order</p>
i want to redirect to this page…
perochak
(Amjad Mughal)
July 2, 2011, 4:25pm
8
Is it not simple to get it by this line of code
$this->redirect(array('thanks','id'=>$model->id));
emil_pgc
(Emil Thushara)
July 4, 2011, 7:13am
9
I Don’t have a model for my confirmation page…
Can u tell me how i can redirect a page to
"ABOUT US"
page which is already in the yii app
perochak
(Amjad Mughal)
July 4, 2011, 7:26am
10
For this,
you need to give the path of the controller and action
$this->redirect(array('site/thanks','id'=>$model->id));
emil_pgc
(Emil Thushara)
July 4, 2011, 7:28am
11
I Don’t have a model for my confirmation page…
Can u tell me how i can redirect a page to
"ABOUT US"
page which is already in the yii app
It’s working for me after i did this
$this->redirect(array('/site/page', 'view'=>'confirmation'));