I am using the validate method to validate user input and when I post a form with errors, I get redirected to the previous page but the form is not repopulated and the errors are not showing. I have include a partial view for showing errors in the page with the form. The partial view is:

```
@if ($errors->any())
   <div class="alert alert-danger">
      <ul>
      @foreach ($errors as $error)
         <li> {{ $error }} </li>
      @endforeach
      </ul>
   </div>
@endif

```

the action method in the controller is:

```
 public function store(Request $request)
    {
        $request->validate([
            'product_name' => 'required',
            'age' => 'required',
            'product_code' => 'required|alpha_num',
            'price' => 'required|numeric',
        ]);
        $product=new Product();

```

The view with the form is:

```
@section('content')
<div class="container">
   @include('partials.errors')
   <form action="/products/create" method="POST">
      <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
      @csrf
      <div class="form-group">
         <label>Product Name</label>
         <input name="product_name" type="text" class="form-control">
      </div>
      <div class="form-group">
         <label>Age</label>
         <input name="age" type="text" class="form-control">
      </div>
      <div class="form-group">
         <label>Gender</label>
         <select class="form-control" name="gender">
            <option>
               Male
            </option>
            <option>
               Female
            </option>
               Unisex
            </option>
         </select>
      </div>
      <div class="form-group">
         <label>Product Code</label>
         <input name="product_code" type="text" class="form-control">
      </div>
      <div class="form-group">
         <label>Price</label>
         <input name="price" type="text" class="form-control">
      </div>
      <div class="form-group">
         <label>Product Category</label>
         <select class="form-control" name="category_name">
            @foreach ($product_categories as $product_category)
               <option>{{ $product_category->category_name }}</option>
            @endforeach
         </select>
      </div>
      <div class="form-group">
         <label>Brand</label>
         <select class="form-control" name="brand_name">
            @foreach ($brands as $brand)
               <option>{{ $brand->brand_name }}</option>
            @endforeach
         </select>
      </div>
      <button class="btn btn-primary" type="submit">Create</button>
   </form>

</div>
@endsection

```

when I post a failed form, I get redirected to the view with the form but the form is not repopulated with the input that I entered. additionally, the erros are not shown but just an empty red div. According to a book I read, if the data isn’t valid, the validate method throws a ValidationException and the exception will return a redirect to the previous page, together with all of the user input and the validation errors. I am new to laravel.