![]() |
Using Form Validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Using Form Validation (/showthread.php?tid=27602) |
Using Form Validation - El Forum - 02-15-2010 [eluser]mikelbring[/eluser] I have the following general code: Code: <?php echo validation_errors('<p>','</p>'); ?> The Code: <p> Using Form Validation - El Forum - 02-15-2010 [eluser]maria clara[/eluser] [quote author="mikelbring" date="1266316908"]I have the following general code: Code: <?php echo validation_errors('<p>','</p>'); ?> The Code: <p> <p></p> are paragraph tags in html. what do intend to do with them?? what o you want to show?? Using Form Validation - El Forum - 02-15-2010 [eluser]mikelbring[/eluser] Well the < p > and < / p > are the prefix and suffix so each error item has the paragraph tags around them. I want to make it so just at the beginning of the error call, there is a item such as "Errors Occurred:" but would only show if there are errors. I am surprised this was not coded into the validation method, unless I am wrong. So I am seeing if any one else ran into this and what they did to work around it. Using Form Validation - El Forum - 02-16-2010 [eluser]JoostV[/eluser] I am guessing this would do the trick Code: echo validation_errors() ? '<div class="errors"><h1>Errors occurred</h1>' . validation_errors() . '</div>' : ''; Using Form Validation - El Forum - 02-16-2010 [eluser]mikelbring[/eluser] That does not seem to work. It act like it returns true no matter what. Using Form Validation - El Forum - 02-16-2010 [eluser]maria clara[/eluser] [quote author="mikelbring" date="1266325696"]That does not seem to work. It act like it returns true no matter what.[/quote] can you post the code concerning it?? EDIT: i have tried it also. and it works fine ![]() Using Form Validation - El Forum - 02-16-2010 [eluser]JoostV[/eluser] Quote:That does not seem to work. It act like it returns true no matter what. I just tested it. It works fine ![]() validation_errors() returns an empty strings if there are no errors in the validation object, and it returns a string if there are. Using Form Validation - El Forum - 02-16-2010 [eluser]mikelbring[/eluser] I pasted your exact code in my view and it returns Errirs occurred even when the form has not be submitted yet. EDIT My fault, I forgot to take something out of the helper I was playing with. Works now, thanks a lot! Using Form Validation - El Forum - 02-16-2010 [eluser]JoostV[/eluser] You're welcome ![]() |