jeudi 29 juin 2017

Laravel Form validation error

What is my problem is if i fill all the data in the form field and Send or not it show the error messages as well as data not going to its database.

Here is the Controller function im talking .

public function store(Request $request)
{

     $this->validate($request, [
                'trainee_id' => 'required',
                'Trainee_Name' => 'required',
                'bank_name' => 'required',
                'branch_name' => 'required',
                'account_no' => 'required',
            ]);

    bankdetails::create($request->all());
        Session::flash('success', 'New Record has been added!');
    return view('bankdetails.bankdetailssucess');
}

This is the view for that.

     <div class="col-md-12">
<div class="row">
  <div class="col-md-8 col-md-offset-2">


            <div class="panel panel-default">
            <div class="panel-heading">
                <h2>Fill Your Bank Details</h2>
            </div>

            <div class="panel-body">



            <form action="" method="post" >
             

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

           &nbsp;  &nbsp;  &nbsp;

                            <div class="form-group">
                            <label>Trainee ID</label>
                            <input type="text" name="trainee_id" class="form-control" value="MOB/TR/">
                            </div>

                            <div class="form-group">
                            <label>Trainee Name</label>
                            <input type="text" name="trainee_name" class="form-control" value="">
                            </div>

                            <div class="form-group">
                            <label>Bank Name</label>
                            <input type="text" name="bank_acc_name" class="form-control" value="">
                            </div>

                            <div class="form-group">
                            <label>Branch Name</label>
                            <input type="text" name="branch_acc_name" class="form-control" value="">
                            </div>

                            <div class="form-group">
                            <label>Account No</label>
                            <input type="text" name="accoun_no" class="form-control" value="">
                            </div>

                             <input type="submit" class="btn btn-success pull-right">


           </form>


            </div>
            </div>
            </div>
            </div>
        </div>

Can anyone say me why im getting this problem.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire