Using Form Validation

#1
[eluser]mikelbring[/eluser]
I have the following general code:
Code:
&lt;?php echo validation_errors('<p>','</p>'); ?&gt;

The
Code:
<p>
of course will show before each item. How can I make it show something just at the top of the errors but not in front of each error, only if there are errors?

#2
[eluser]maria clara[/eluser]
[quote author="mikelbring" date="1266316908"]I have the following general code:
Code:
&lt;?php echo validation_errors('<p>','</p>'); ?&gt;

The
Code:
<p>
of course will show before each item. How can I make it show something just at the top of the errors but not in front of each error, only if there are errors?[/quote]

<p></p> are paragraph tags in html. what do intend to do with them?? what o you want to show??

#3
[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.

#4
[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>' : '';

#5
[eluser]mikelbring[/eluser]
That does not seem to work. It act like it returns true no matter what.

#6
[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 Tongue

#7
[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 Smile
validation_errors() returns an empty strings if there are no errors in the validation object, and it returns a string if there are.

#8
[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!

#9
[eluser]JoostV[/eluser]
You're welcome Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.