Forward data from one controller action to other in Yii2
Is it possible to forward data from one controller action to other before the render? Basically, I want to now if we have something that Zend _forward does?
Here is my scenario. I have a payment gateway that returns data back to my controller action, what I want is to handle data on separate controller/action but render the home page (without redirection). Is it possible to forward control from one controller/action to other ?
Can anybody suggest me can I go for ?
php yii2
add a comment |
Is it possible to forward data from one controller action to other before the render? Basically, I want to now if we have something that Zend _forward does?
Here is my scenario. I have a payment gateway that returns data back to my controller action, what I want is to handle data on separate controller/action but render the home page (without redirection). Is it possible to forward control from one controller/action to other ?
Can anybody suggest me can I go for ?
php yii2
You could simply extract the relevant part of your controller to another method and use it on both. Is this an option?
– dminones
Jan 31 '15 at 14:14
@dminones No I want complete render
– alwaysLearn
Jan 31 '15 at 14:20
did you try this: $this->actionIndex($data); It should work
– dminones
Jan 31 '15 at 14:34
@dminones my action is in different controller
– alwaysLearn
Jan 31 '15 at 14:40
Ok, is more clear now, did you see this stackoverflow.com/questions/10323576/…?
– dminones
Jan 31 '15 at 14:47
add a comment |
Is it possible to forward data from one controller action to other before the render? Basically, I want to now if we have something that Zend _forward does?
Here is my scenario. I have a payment gateway that returns data back to my controller action, what I want is to handle data on separate controller/action but render the home page (without redirection). Is it possible to forward control from one controller/action to other ?
Can anybody suggest me can I go for ?
php yii2
Is it possible to forward data from one controller action to other before the render? Basically, I want to now if we have something that Zend _forward does?
Here is my scenario. I have a payment gateway that returns data back to my controller action, what I want is to handle data on separate controller/action but render the home page (without redirection). Is it possible to forward control from one controller/action to other ?
Can anybody suggest me can I go for ?
php yii2
php yii2
edited Nov 24 '18 at 0:22
Marcus Campbell
2,01921027
2,01921027
asked Jan 31 '15 at 13:02
alwaysLearnalwaysLearn
4,65952955
4,65952955
You could simply extract the relevant part of your controller to another method and use it on both. Is this an option?
– dminones
Jan 31 '15 at 14:14
@dminones No I want complete render
– alwaysLearn
Jan 31 '15 at 14:20
did you try this: $this->actionIndex($data); It should work
– dminones
Jan 31 '15 at 14:34
@dminones my action is in different controller
– alwaysLearn
Jan 31 '15 at 14:40
Ok, is more clear now, did you see this stackoverflow.com/questions/10323576/…?
– dminones
Jan 31 '15 at 14:47
add a comment |
You could simply extract the relevant part of your controller to another method and use it on both. Is this an option?
– dminones
Jan 31 '15 at 14:14
@dminones No I want complete render
– alwaysLearn
Jan 31 '15 at 14:20
did you try this: $this->actionIndex($data); It should work
– dminones
Jan 31 '15 at 14:34
@dminones my action is in different controller
– alwaysLearn
Jan 31 '15 at 14:40
Ok, is more clear now, did you see this stackoverflow.com/questions/10323576/…?
– dminones
Jan 31 '15 at 14:47
You could simply extract the relevant part of your controller to another method and use it on both. Is this an option?
– dminones
Jan 31 '15 at 14:14
You could simply extract the relevant part of your controller to another method and use it on both. Is this an option?
– dminones
Jan 31 '15 at 14:14
@dminones No I want complete render
– alwaysLearn
Jan 31 '15 at 14:20
@dminones No I want complete render
– alwaysLearn
Jan 31 '15 at 14:20
did you try this: $this->actionIndex($data); It should work
– dminones
Jan 31 '15 at 14:34
did you try this: $this->actionIndex($data); It should work
– dminones
Jan 31 '15 at 14:34
@dminones my action is in different controller
– alwaysLearn
Jan 31 '15 at 14:40
@dminones my action is in different controller
– alwaysLearn
Jan 31 '15 at 14:40
Ok, is more clear now, did you see this stackoverflow.com/questions/10323576/…?
– dminones
Jan 31 '15 at 14:47
Ok, is more clear now, did you see this stackoverflow.com/questions/10323576/…?
– dminones
Jan 31 '15 at 14:47
add a comment |
2 Answers
2
active
oldest
votes
In Yii 2, you can use this which yields the same result of forward():
Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
if you want to render this in a modal, add$this->layout = false;to your controller action
– Ruben
Feb 18 '16 at 9:26
add a comment |
As far as I know Yii 1 had forward method in controller that allowed you to forward to different controller/action with simply:
$this->forward("new_controller/new_action");
I'm sure something similar could be working in Yii2 too.
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
2
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28251890%2fforward-data-from-one-controller-action-to-other-in-yii2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In Yii 2, you can use this which yields the same result of forward():
Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
if you want to render this in a modal, add$this->layout = false;to your controller action
– Ruben
Feb 18 '16 at 9:26
add a comment |
In Yii 2, you can use this which yields the same result of forward():
Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
if you want to render this in a modal, add$this->layout = false;to your controller action
– Ruben
Feb 18 '16 at 9:26
add a comment |
In Yii 2, you can use this which yields the same result of forward():
Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
In Yii 2, you can use this which yields the same result of forward():
Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
edited May 17 '16 at 5:53
answered May 25 '15 at 7:11
MaheshMahesh
411619
411619
if you want to render this in a modal, add$this->layout = false;to your controller action
– Ruben
Feb 18 '16 at 9:26
add a comment |
if you want to render this in a modal, add$this->layout = false;to your controller action
– Ruben
Feb 18 '16 at 9:26
if you want to render this in a modal, add
$this->layout = false; to your controller action– Ruben
Feb 18 '16 at 9:26
if you want to render this in a modal, add
$this->layout = false; to your controller action– Ruben
Feb 18 '16 at 9:26
add a comment |
As far as I know Yii 1 had forward method in controller that allowed you to forward to different controller/action with simply:
$this->forward("new_controller/new_action");
I'm sure something similar could be working in Yii2 too.
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
2
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
add a comment |
As far as I know Yii 1 had forward method in controller that allowed you to forward to different controller/action with simply:
$this->forward("new_controller/new_action");
I'm sure something similar could be working in Yii2 too.
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
2
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
add a comment |
As far as I know Yii 1 had forward method in controller that allowed you to forward to different controller/action with simply:
$this->forward("new_controller/new_action");
I'm sure something similar could be working in Yii2 too.
As far as I know Yii 1 had forward method in controller that allowed you to forward to different controller/action with simply:
$this->forward("new_controller/new_action");
I'm sure something similar could be working in Yii2 too.
answered Feb 3 '15 at 2:42
Alexandru Trandafir CatalinAlexandru Trandafir Catalin
1,76922233
1,76922233
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
2
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
add a comment |
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
2
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
May be a little lazy for not googling, but who's paying for that? This is a correct answer. The second (aded 3 months later) simply clarifies details.
– nssmart
Jun 2 '16 at 6:33
2
2
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
He asked for the Yii2 version
– Skatox
Jan 18 '17 at 18:32
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28251890%2fforward-data-from-one-controller-action-to-other-in-yii2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You could simply extract the relevant part of your controller to another method and use it on both. Is this an option?
– dminones
Jan 31 '15 at 14:14
@dminones No I want complete render
– alwaysLearn
Jan 31 '15 at 14:20
did you try this: $this->actionIndex($data); It should work
– dminones
Jan 31 '15 at 14:34
@dminones my action is in different controller
– alwaysLearn
Jan 31 '15 at 14:40
Ok, is more clear now, did you see this stackoverflow.com/questions/10323576/…?
– dminones
Jan 31 '15 at 14:47