Form validation question |
[eluser]Unknown[/eluser]
Hello! I would like to know how can I implement form validation without making another view for the form. My working code is the one shown in the video tutorial from CI's website (the blog). I would like to validate the comment adding form. Here is the code for comments_view.php and here is the one for blog.php Any suggestions? Thanks in advance.
[eluser]gtech[/eluser]
hey have you checked out the validation documentation? [url="http://ellislab.com/codeigniter/user-guide/libraries/validation.html"](click here)[/url] its quite well documented, I think what your asking is that you want to redisplay the same form view if it is not validated correctly and display the error messages, if thats the case then there are a few examples in the validation documentation.
[eluser]Michael Wales[/eluser]
Make your form action the same method that displays the form. Place all of your validation in that form and then use the run() method of the Validation class to determine whether you need to perform a database insert or not. Code: if ($this->validation->run()) {
[eluser]Unknown[/eluser]
Can you guys give me an example using the code I have provided at pastebin? I don't seem to get it working ![]()
[eluser]Michael Wales[/eluser]
I'll just write up some code here - just because I'm to drunk to go clicking on links (is it Drunken tut time?). Controller Code: function login() {
[eluser]Chris Newton[/eluser]
I posted some validation stuff into your code at your collaboration site. I'll echo what gtech mentioned though... the docs are pretty detailed in this particular area. |
Welcome Guest, Not a member yet? Register Sign In |