My Issue:
If my user session times out while an access restricted page is visible (say I left it open overnight), and the user then clicks on a button that performs an ajax call, the login required display appears within the div that the ajax update should happen in, rather than replacing the entire current page.
Potential Solutions:
Option 1) Extend the CWebUser and override the loginRequired() function to check for $request->isAjaxRequest (this would then need to redirect to a page which causes a javascript redirect)
Option 2) Modify the Site actionLogin to check the request type and render a different page which causes a javascript redirect.
Option 2 is the least invasive method, so I am going to go with that option and see how things work out ;)
Site Note: Could override the controller->redirect method, but I don't want to necessarily block all redirects -- I can forsee needing to have one ajax view action redirect to another ajax view action. If the controller override was used, it would have to be done on every controller - hardly efficient.
Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts
Wednesday, April 14, 2010
Wednesday, March 31, 2010
Posting with multiple models
I spent a good bit of time trying to figure out how to render multiple models in a form and have them each validate properly.
Knowing the solution, it seems quite obvious, but it took a while to track down the proper syntax.
In this example I have a custom CForm which contains a few different $model properties, in addition to the base form data.
To call the validation on multiple models in the form, simply modify any calls of
Knowing the solution, it seems quite obvious, but it took a while to track down the proper syntax.
In this example I have a custom CForm which contains a few different $model properties, in addition to the base form data.
To call the validation on multiple models in the form, simply modify any calls of
CActiveForm::validate($model);to use an array of models as the first parameter as such:
CActiveForm::validate( array($model, $model->subModel, $model->subModel2) );
Labels:
ajax,
CActiveForm,
models,
post,
validation,
yii
Subscribe to:
Posts (Atom)