Welcome Guest, Not a member yet? Register   Sign In
using validation_errors() inside controller?
#1

[eluser]fivestringsurf[/eluser]
Hey folks,
How do i echo validation errors from a controller?

I'm using jquery to perform an ajaxian type call to the controller. all my values pass to and from with no problems.
where i am running into trouble is with echoing out the validation errors using validation_errors()

using echo validation_errors(); seems to work in a view but not a controller?
all i need to do is echo out my validation errors from the controller and i will have myself a nifty ajax form validation service using jquery and codeigniter.

any suggestions?
#2

[eluser]crikey[/eluser]
Could you just make a view that outputs the errors using validation_errors(), load the view into a variable in your controller, and echo the variable?

A bit of a roundabout way, but at least it keeps your output separate from your controller logic.
#3

[eluser]fivestringsurf[/eluser]
Thanks for your response...sorry for the delay; Thanksgiving really swamped me.
Anyway, I got to the bottom of the problem.

I was calling exit(); immediately follwing the validation_errors() function and for some reason that was causing them not to print;
Strange; why would that be?
I ordered the script to stop after echoing the function.

Can anyone shed some light upon this?
#4

[eluser]keithics[/eluser]
how about this..

if ($this->form_validation->run() == false)
{
echo validation_errors();


} else
{

}
exit;




Theme © iAndrew 2016 - Forum software by © MyBB