Question

i'm trying to update the data in my DB table called "users", specifically 3 columns. But now i'm just trying to communicate with a controller to get an echo!! I have the following code:

My view file (dashboard.blade.php) has a form in it:

  <div class="small-12">
    {{ Form::open(array('action' => 'UsersController@putCoordinates')) }}
    <div class="row">
      <div class="small-3 columns">
        <label for="city" class="right inline"><i class="fa fa-chevron-right"></i></label>
      </div>
      <div class="small-9 columns">
        {{ Form::text('city', null, array('id'=>'city', 'placeholder'=>'current city', 'required'=>'required')) }}
      </div>
    </div>
    <div class="row">
      <div class="small-3 columns">
        <label for="markerLat" class="right inline"><i class="fa fa-chevron-right"></i></label>
      </div>
      <div class="small-9 columns">
        {{ Form::text('markerLat', null, array('id'=>'markerLat', 'placeholder'=>'latitude', 'required'=>'required')) }}
      </div>
    </div>
    <div class="row">
      <div class="small-3 columns">
        <label for="markerLng" class="right inline"><i class="fa fa-chevron-right"></i></label>
      </div>
      <div class="small-9 columns">
        {{ Form::text('markerLng', null, array('id'=>'markerLng', 'placeholder'=>'longitude', 'required'=>'required')) }}
      </div>
    </div>
    <div class="row">
      <div class="small-12 columns">
        {{ Form::button('Update', array('class'=>'button small addMe postfix', 'id'=>'addMe'))}}
      </div>
    </div>
    {{ Form::close() }}
  </div>

the route i created is:

Route::controller('users', 'UsersController');

And in the controller file (UsersController) i have the following function:

    public function putCoordinates() {  
        echo "It works!";
    }

But so far, it doesn't seem to be working.. i've tried to change my openning form to:

{{ Form::open(array('url'=>'users/update', 'class'=>'form')) }}

but it didn't work, i dont get any error, i just press "update" and nothing happens..

Any help would be appreciated, i must be missing something very simple here. Thanks!

Was it helpful?

Solution

Default method is POST, so you need to tell Laravel to create your form using the method PUT:

{{ Form::open(array('method' => 'PUT', 'action' => 'UsersController@putCoordinates')) }}

And, to create your submit button you must use:

{{ Form::submit('Update', array('class'=>'button small addMe postfix', 'id'=>'addMe'))}}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top