I have a form view in which the user chooses what to display and then hits a submit button. This is working fine.
What I can’t figure out is how to use the controller to open a new view on a new browser tab to display the chosen graphical output.
I know this is truly beginning stuff, but I can’t find how to do it in the documentation. Would somebody please show me how or point me where to look to figure this out?
you render a view in your controller or render partially in your view but if you open a new page from your form that new page will be /controller/action and there you decide what view to render
example (very basic)
i go to /site/index
in my SiteController there is an actionIndex , which decides what view to render etc
let’s take the index.php view to keep it easy
now if on that view i have a link to href=/site/otherpage with target="_BLANK" it will open a new tab/window (depends on the browsers settings)
on that moment we load SiteController -> actionOtherpage and there you decide again what view to render
try out the tutorials first, they are very helpfull. maybe read up how MCV works
Look, I don’t care how this works, and I realize that I am probably missing something very rudimentary. I just want this to work.
I want to collect information from the user using a form view, then when the submit button is hit, I want to generate a new browser tab that uses the information I collected on the form to generate some view output on a new browser tab. I can get this to work using the same browser tab. What do I have to do to render a view on a new browser tab?
ofc this is just to explain what i mean, i’m sure that if i took my time there are better ways to rewrite this, even better to go with the yii framework but that’s basicly what you want
Okay, what you want is to use the target attribute of the form. Reading this page on w3schools is a good place to start. Assuming you’re using a CActiveForm widget or similar, the way to set this attribute is using the htmlOptions property:
I’m very grateful for all the help here. I’m sorry if I sounded upset. Quite the contrary.
I may be a bit frustrated at myself because I don’t understand some very basic things, but I am extremely grateful to everyone who has ever taken mercy on me enough to respond to my ignorant questions.
You have a big problem here (IMO), because if you don’t care how it works you will not understand the answers you get here and you will not get it to work… people can just give you directions in solving the problem you have, but in the end, you are the one that has to do the coding and apply the solution you get here…
OK, I thought that this had solved my problem, but this opens up a whole new set of problems instead. What I want to do is it render, not link, a view in its own window. I want to somehow to use my controller to open up a new target window in which to render a view if and only if the form validates after the select button is pushed.
When I use change the form to ‘target’=>’_blank’ I get a new tab/window every time the submit button is pushed whether or not the form validates. This is unacceptable. I only want to open a new tab/window when the form entries are valid.
I also continue to have a problem with my dependent drop down field whose selected values always disappear upon validation.
Does anyone have any advice for a truly desperate soul? I am so close to having this working, yet still so far.
General comment / advise: No matter, what solution will be proposed to solve this problem, it is IMHO worth noting that at the very end it is browser, which decides how to handle target="_blank" attribute. Try to realize that it is browser not your webpage, which actually opens new tab or new window. And it is actually up to webbrowser developers not yourself to make 100% if that tab or window will be opened for you! This may lead into serious problems, if you design and develop your application with assumption that results of any operation will be displayed in new tab or window. And what, if not?
And there are at least rummors, if not confirmed information, that this attributte will shortly became deprecated - i.e. newest versions of webbrowsers will stop handling it! As global movement is toward idea that it is up to user not the browser or webpage creator to decide whether particular webpage should be displayed in the same or in a new window or browser tab.
Modern, professional webpages and browser utilizes this idea in manner that left-button-click in any link or button opens results always in the same window or tab while middle-button-click always opens it in new windows or tab. This way user decides and this is how it should always be IMHO. Try to understand that deciding for end user on if he or she want or doesen’t want to see results in new window / tab or to dedide for him in any other matter may only force your users / customers to decide to look for a better website.
Therefore, conlusion is that profesional webdevelopers should not focus on how to force browser to open anything in new window or tab as this feature might be terminated permanently shortly. It would be better to focus on how to rewrite or redesign application for not using this feature at all. jQuery UI or any other JS framework modal dialogs / message boxes would be a good idea to look for. They work for sure and even look much better, because you can style them with CSS.
I read all the thread hoping that in the end (or on the way) there will be a solution, because I have the same problem, but the question stayed without answer.
my problem is that:
The webpage needs to check the form with the server, and in case that everything is alright it gets a url address from the server and opens it in a new tab. the url is for paying in paypal.
The problem was that each time I checked it the chrome treated it as a popup, and I thought that every use of window.open in js will cause the browser to behave like that. maybe it was because I checked it in debugging mode, or other circumstances that could made it.