I want a "Quick Quote" form that goes in the sidebar of my site on every page.
I read in the forums that the best way to do this is by putting your form into a widget. Fair enough…That’s what I have done.
My form action points to the route site/quickQuote, displayed below…
public function actionQuickQuote()
//Process stuff here
//Redirect to success page
//WHAT GOES HERE??? => $this->render('contact',array('model'=>$model));
What should I do if validation fails? Normally you would have to render the form again… but the form can be submitted from any page on my site so I don’t know what to do anymore.
I would like your input on the best way to do this whole sidebar form thing. Thanks.
I think you don’t need to do that if you have rules defined in the model, if you have then a validate will issue an error automatically if it fails to validate.
Thanks for your reply…
But you need to render a view else there is no form for the error messages to be displayed on.
Enable client side validation as well as ajax validation.
Also, submit form via ajax, thus rest of the page won’t have to be refreshed.
Take a look at this, i think it would be helpful
Depending only on client-side validation is not a good choice - what if someone disabled JS in browser or just wrote a bot to flood your database?
in my opinion you could follow one of 2 scenarios here:
prepare specific view ‘quicknote’ which focuses on note posting form and allows user to correct errors and resubmit his note
use Yii::app()->request->urlReferrer and redirect back to page from which user posted his invalid note. You could add flash message and show it on that page that posting a note was unsuccessful…