SetFlash, hasFlash, and getFlash are used to create the TestController. php file in protected/controllers to display information when you submit a form.
When you submit a form and want to display information to the user, you need to use setFlash, hasFlash, and getFlash to create the TestController. php file in protected/controllers. the content is as follows:
?
1234567891011121314151617 |
ClassTestControllerextendsCController {functionactionOk () {Yii: app ()-> user-> setFlash ('success ', 'everything went fine! '); $ This-> redirect ('index');} functionactionBad () {Yii: app ()-> user-> setFlash ('error ', 'Everything went wrong! '); $ This-> redirect ('index');} functionactionIndex () {$ this-> render ('index ');}} |
Create the index. php file in protected/views/test:
?
1234567891011 |
User-> hasFlash ('success'):?> User-> getFlash ('success')?> User-> hasFlash ('error'):?> User-> getFlash ('error')?> |