Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show the error messages in ajax #13

Open
sureshamk opened this issue May 26, 2014 · 1 comment
Open

show the error messages in ajax #13

sureshamk opened this issue May 26, 2014 · 1 comment

Comments

@sureshamk
Copy link

i used your validation library . its nice and helped a lot to me . but now i am getting one issue . i need to show the error messages only as a response . how can i achieve this ?

my code is

$dog = new dog(Input::all());
        if (Request::ajax()) {
            if (!$dog->save()) {
                if ($dog->hasErrors()) {
                    return Response::json(array(
                        'success' => false,
                        'errors' => $dog->getErrors(),
                                      ), 200); 
                }
            }

        }
@molovo
Copy link

molovo commented Oct 17, 2014

This isn't a bug. You can include the errors in an Ajax response by calling $dog->getErrors()->toArray(). This is necessary as the messages attribute of the object returned by getErrors() is protected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants