Error and success messages from form builder

This commit is contained in:
Miguel Nogueira 2020-05-06 23:16:34 +01:00
parent 8d79345095
commit f52b249834
4 changed files with 65 additions and 7 deletions

View File

@ -11,7 +11,12 @@ class FormController extends Controller
public function index()
{
return view('dashboard.administration.forms');
}
public function showFormBuilder()
{
return view('dashboard.administration.formbuilder');
}
public function saveForm(Request $request)
@ -54,11 +59,11 @@ class FormController extends Controller
]
);
$request->session()->flash('sucesss', 'Form created! You can now link this form to a vacancy.');
$request->session()->flash('success', 'Form created! You can now link this form to a vacancy.');
return redirect()->back();
}
$request->session()->flash('errors', $validation->errors());
$request->session()->flash('errors', $validation->errors()->getMessages());
return redirect()->back();
}

View File

@ -274,9 +274,20 @@ return [
'url' => '/admin/positions'
],
[
'text' => 'Manage Forms',
'text' => 'Forms',
'icon' => 'fab fa-wpforms',
'url' => '/admin/forms'
'submenu' => [
[
'text' => 'All forms',
'icon' => 'far fa-list-alt',
'url' => '/admin/forms'
],
[
'text' => 'Form Builder',
'icon' => 'fas fa-fw fa-hammer',
'url' => '/admin/forms/builder'
]
]
]
]
],
@ -336,7 +347,7 @@ return [
'plugins' => [
[
'name' => 'Datatables',
'active' => true,
'active' => false,
'files' => [
[
'type' => 'js',
@ -420,5 +431,21 @@ return [
],
],
],
[
'name' => 'Toastr',
'active' => true,
'files' => [
[
'type' => 'js',
'asset' => false,
'location' => 'https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js'
],
[
'type' => 'css',
'asset' => false,
'location' => 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css'
]
]
]
],
];

View File

@ -8,6 +8,28 @@
@stop
@section('js')
@if (session()->has('success'))
<script>
toastr.success("{{session('success')}}")
</script>
@elseif(session()->has('error'))
@foreach(session('error') as $error)
<script>
toastr.error("{{$error}}")
</script>
@endforeach
@endif
@stop
@section('content')
<div class="row">
@ -41,6 +63,7 @@
<div class="card-footer text-center">
<button onclick="save()" type="button" class="btn btn-success">Save Form</button>
<button type="button" class="btn btn-info">Form List</button>
</div>

View File

@ -67,12 +67,15 @@ Route::group(['middleware' => 'auth'], function(){
Route::resource('positions', 'VacancyController');
Route::get('forms', 'FormController@index')
Route::get('forms/builder', 'FormController@showFormBuilder')
->name('showFormBuilder');
Route::post('forms/save', 'FormController@saveForm')
->name('saveForm');
Route::get('forms', 'FormController@index')
->name('showForms');
});
});