Form not submitting

Posted 3 months ago by TimeSocks

Hi there,

I'm encountering a very strange problem while going through the Birdboard series. I have made a simple form for creating a project as per episode 7:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <h1>Create a project</h1>
    <form action="/projects" method="post">
      @csrf
      <input type="text" name="title" value="">
      <input type="text" name="description" value="">
      <button type="button" name="button" type="submit">Submit</button>
    </form>
  </body>
</html>

This just doesn't submit. I click the button and nothing happens. I have tried a dd in the relevant method in the controller, but it never triggers, like it's not even getting that far. FWIW here is the store() method:

public function store()
    {
      //validate
      $attributes = request()->validate([
        'title' => 'required',
        'description' => 'required',
      ]);

      //persist
      auth()->user()->projects()->create($attributes);

      //redirect
      return redirect('/projects');
    }

And the route file:

Route::group(['middleware' => 'auth'], function(){
  Route::get('/projects/create', '[email protected]');
  Route::get('/projects/{project}', '[email protected]');
  Route::get('/projects', '[email protected]');
  Route::post('/projects', '[email protected]');
  Route::get('/home', '[email protected]')->name('home');
});

What gives?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.