Saturday, April 15, 2017

Form data not updating

I have a huge form data with more than 50 fields that i need to update,

The view driver-details.blade.php

<form id="example-form" enctype="multipart/form-data" action="">
    <input type="hidden" name="_method" value="PUT">
    {!! csrf_field() !!}
    <div class="modal-content">
            <div class="row">
                <div class="col s12 no-padding" style="margin-bottom: 15px">
                    <ul class="tabs tab-demo z-depth-1" style="width: 100%;">
                        <li class="tab col s3"><a class="active" href="#test5">Registration Details</a></li>
                        <li class="tab col s3"><a href="#test6">Personal Details</a></li>
                    </ul>
                </div>
                <div id="test5" class="col s12">
                    <div class="row">
                        <div class="input-field col m12 s12">
                            <input name="event_name" type="text" class="required validate" value="">
                            <label for="event_name" class="active">Event Name</label>
                        </div>
                        <div class="input-field col m12 s12">
                            <input name="sponsor_name" type="text" class="required validate" value="">
                            <label for="sponsor_name" class="active">Sponsor Name</label>
                        </div>
                    </div>
                </div>                         
                <div id="test6" class="col s12">
                    <div class="row">
                        <div class="input-field col m6 s12">
                            <input id="first_name" name="first_name" type="text" class="required validate">
                            <label for="first_name" class="active">First Name</label>
                        </div>
                        <div class="input-field col m6 s12">
                            <select class="initialized" name="role">
                                @if($driver->role == 'NA')
                                    <option name="role" value="">Choose Role</option>
                                @else
                                    <option name="role" value=""></option>
                                @endif
                                @foreach($roles as $role)
                                    @if($driver->role != $role->name)
                                        <option name="role" value=""></option>
                                    @endif 
                                @endforeach
                            </select>
                            <label>Role</label>
                        </div>
                        <!--so on..............-->
                    </div>
                </div>
            </div>
        </div>
    </form>

in my Controller i'm trying mass update

    public function updateDriver(Request $request, $id)
    {
        $form_data = Input::all();

        Driver::find($id)->update($form_data);

        return $this->respondUpdated('Driver updated successfully');
    }


    //route

    Route::put('driver/{id}', 'DriversController@updateDriver');

when i submit the form it just reloads the page but no changes in database, and in the url i get this

http://localhost:8000/driver-details/1?_method=PUT&_token=dEY8y58oCWrdsTYJreMhx5X7eMRoorUHqQ7jlBv5&event_name=Enent+Name&sponsor_name=Sponser&first_name=   so on.......

i don't know what i'm missing,

thank you



via Mr Robot

Advertisement