0

This is my Request page: request

{!! \JsValidator::formRequest('App\Http\Requests\Backend\UserRequest', '#my-form') !!}

im trying like this with Laravel JS Validation. But i have some errors like this: errors

I'm using the form like this:

{!! Form::model($user, ['class' => 'form-horizontal form-bordered', 'route' => ['admin.user.update', $user->id], 'method' => 'PATCH', 'id' => 'my-form']) !!}
6
  • What package are you using for validation? Commented Dec 16, 2015 at 13:19
  • github.com/proengsoft/laravel-jsvalidation Commented Dec 16, 2015 at 13:20
  • It would seem your rules method in your form request object is not returning anything, likely because you have not accounted for GET. If a get request is outputting the form, the method is going to be equal to GET even if the form's method is post. Commented Dec 16, 2015 at 13:34
  • im added how i using form at question Commented Dec 16, 2015 at 13:40
  • The problem is a GET request is being used to generate the form. When the js validation package is trying to reach into the rules method in your form request object, the method is GET. Try adding case 'GET': right above case 'PUT':. Commented Dec 16, 2015 at 13:42

1 Answer 1

1

I solved it like this:

if (\Request::segment(3) == "create")
    return [
        'name'                  => 'required',
        'email'                 => 'required|email|unique:users,email,'.\Request::segment(3),
        'password'              => 'required|min:5|confirmed',
    ];
else
    return [
        'name'                  => 'required',
        'email'                 => 'required|email|unique:users,email,'.\Request::segment(3),
        'password'              => 'min:5|confirmed',
    ];

Maybe it is solves other people's problems. Thanks for interesting my questions...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.