Ignore the ```marks. Those are not in the original code. I was trying to set my code up to display correctly in the question.
Submit Button is Doing Nothing
Hello, I have been trying to determine why the submit button in my HTML form is not working. When I click on it I get no errors in the console and no exceptions. It does nothing. I have tried many of the suggestions on Laracasts and StackOverflow, but have found nothing that works. It may be something very simple and if so, I apologize. I am still fairly new at Laravel.
I have tried to name my Route::post('/posts/store', 'PostController@store'), but that did not work. I have tried the code below, but nothing is working.
action="{{ action('PostController@store') }}" action="{{ route('posts/store') }}" action="{{ route('posts.store') }}" (This was after giving it a name of posts.store) action="{{ URL('posts/store') }}"
Laravel 5.7 PHP 7.2.10 Ubuntu 18.04
create.blade.php
<div class="container">
<div class="row">
<div class="col-lg-3"></div>
<div class="col-md-9">
<h1>Enter New Blog Post</h1>
<hr>
<div class="form-group">
<form method="POST" action="{{ action('PostController@store') }}">
<label for="title">Title</label>
<input class="form-control" id="title" name='title' type="text"></input>
</div>
<div class="form-group">
<label for="post">Blog Post</label>
<textarea class="form-control" id="post" name='post' ></textarea>
</div>
<button type="submit" class="btn btn-secondary btn-md m-1">Publish New Post</button>
</form>
</div>
</div>
</div>
</div>
@endsection```
PostController
```public function store(Request $request)
{
// validate the data
$validatedData = $request ->validate([
'title' => 'required | unique:posts | max:255',
'post' => 'required'
]);
// store in database
$post -> title = $request -> input('title');
$post -> post = $request -> input('post');
$post->save();
Session::flash('success', 'The blog post was saved successfully!');
// redirect to another
return redirect()->route('posts.show', $post ->id);
}```
web.php
```Route::get('/posts/show', 'PostController@show');
Route::resource('/posts', 'PostController');
Route::post('/posts/store', 'PostController@store');
Route::post('/posts/create', 'PostController@create');```
PagesController
``` public function store() {
return view('posts/store');
}
public function create() {
return view('posts/create');
}
public function show(){
return view('posts/show');
}```
Please or to participate in this conversation.