Reputation: 69
I'm looking for sample code of Laravel contact form with confirm view
I asked this question
https://stackoverflow.com/questions/53853687/adding-live-search-script-into-laravel-form
I'm thinking restart to make contact page that not using {!! Form::
way
that can combine ajax live search section.
I've been searching sample code that contact form with confirm view but I couldn't find it. Doesn't call "confirm view" ?
Could someone teach me how to call it please?
<div class="form-group{{ $errors->has('search') ? ' has-error' : '' }}">
{!! Form::label('search', 'search:', ['class' => 'col-sm-2 control-label']) !!}
<div class="col-sm-10">
{!! Form::text('search', null, ['class' => 'form-control']) !!}
@if ($errors->has('search'))
<span class="help-block">
<strong>{{ $errors->first('search') }}</strong>
</span>
@endif
</div>
</div>
Upvotes: 0
Views: 1404
Reputation: 1381
Then 2nd page is only confirmation page.
I don't see the reason for splitting this up over 3 pages.
If you are just looking to add a confirmation step in there, have you thought about using onclick to prompt the user to confirm? Saves you from jumping around pages and accomplishes what I think you're getting after here.
If the user input passes validation, your controller processes the data and sends you to the thank you page. If it doesn't, it directs the user back to the form page and tells them what the error was.
Routes file:
Route::post('/your/route', 'YourController@store');
input-form.blade.php:
<form method="POST" action="/your/route">
@csrf
<!-- add your form inputs -->
<input type="text" name="fname" class="form-control" />
<input type="email" name="email" class="form-control" />
<button class="btn" onclick="return confirm('Are you sure your credentials are correct?')">
</form>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
YourController:
public function store(Request $request)
{
// You'd want to expand on this a bit
$validatedData = $request->validate([
'fname' => required,
'email' => required
]);
// Process your data ...
// Then, return to your confirmation page
return view('thankyou-page');
}
thankyou-page.blade.php
<div class="container">
<div class="col-md-10">
Thank you, your order is confirmed!
</div>
<!-- col -->
</div>
<!-- container -->
You can scroll through Laravels amazing documentation here that speaks to form validation more.
Upvotes: 2