-
Notifications
You must be signed in to change notification settings - Fork 13
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
Usage Help #13
Comments
Hi @lucadegasperi, Can you post the HTML of your form here, please? |
Sure! This is the login form of a Laravel app. <form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}" id="login-form" data-remote="true">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" autofocus>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password">
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Login
</button>
<a class="btn btn-link" href="{{ url('/password/reset') }}" data-turbolinks-action="advance">
Forgot Your Password?
</a>
</div>
</div>
</form> On failure this procedure is ran: return response()->redirectTo('login')
->withHeaders(['X-Turbolinks' => 'advance'])
->withInput($request->input())
->withErrors($errors, $this->errorBag()); |
The browser console shows that the ajax request for submitting the form is called correctly |
You should use the https://github.com/efficiently/jquery-laravel/tree/2.2 package. composer require efficiently/jquery-laravel:2.2.* Add this service provider to your Efficiently\JqueryLaravel\JqueryLaravelServiceProvider::class, You can now add this security Middleware to the protected $middleware = [
//...
\Efficiently\JqueryLaravel\VerifyJavascriptResponse::class,
]; Then, edit your //...
class Controller extends BaseController
{
//...
use \Efficiently\JqueryLaravel\ControllerAdditions;
//...
} |
Thank you, But I'd like to understand how things work from a basic point of view before relying on some library that hides the complexity away (and form the name requires jQuery as well), Would you be able to help me learn all this? Basically giving different types of inputs what should happen if turbolinks is put in the mix. |
Can you try this: return response()->redirectTo('login')
->withHeaders(['X-Turbolinks' => 'replace'])
->withInput($request->input())
->withErrors($errors, $this->errorBag()); |
That's what I tried above :) Has this happened to you as well? |
For more information, see helthe/Turbolinks#10 (comment) and https://github.com/frenzyapp/turbolinks/blob/3.0.0/src/Frenzy/Turbolinks/TurbolinksServiceProvider.php#L85 |
Hello, I've integrated this package into my app. All the script are included inside the page (turbolinks and jquery ujs). I have a login page but when trying to submit the page nothing happens. Validation does not fire. Is there a good example I can look at for this?
Thanks
The text was updated successfully, but these errors were encountered: