0

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="{{route('bankdetails.store')}}" method="post" >
            {{ csrf_field() }} 

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

           &nbsp;  &nbsp;  &nbsp;

                            <div class="form-group{{ $errors->has('trainee_id') ? ' has-error' : '' }}">
                            <label>Trainee ID</label>
                            <input type="text" name="trainee_id" class="form-control" value="MOB/TR/">
                            </div>

                            <div class="form-group{{ $errors->has('trainee_name') ? ' has-error' : '' }}">
                            <label>Trainee Name</label>
                            <input type="text" name="trainee_name" class="form-control" value="">
                            </div>

                            <div class="form-group{{ $errors->has('bank_acc_name') ? ' has-error' : '' }}">
                            <label>Bank Name</label>
                            <input type="text" name="bank_acc_name" class="form-control" value="">
                            </div>

                            <div class="form-group{{ $errors->has('branch_acc_name') ? ' has-error' : '' }}">
                            <label>Branch Name</label>
                            <input type="text" name="branch_acc_name" class="form-control" value="">
                            </div>

                            <div class="form-group{{ $errors->has('accoun_no') ? ' has-error' : '' }}">
                            <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.

1 Answer 1

1

The name attributes in your view should match to the rules on controller.

$this->validate($request, [
  'trainee_id' => 'required',
  'Trainee_Name' => 'required', // is Case sensitive?
  'bank_name' => 'required', // bank_name exist in your form?
  'branch_name' => 'required', // branch_name exist in your form?
  'accoun_no' => 'required', // In HTML you wrote account_no and here is accoun_no
]);
Sign up to request clarification or add additional context in comments.

3 Comments

this take form id attribute value?
or its just the name attribute?
Just the name attr.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.