Hi all,
I'm using the x-editable script to edit form fields inline, but after trying to save to the database with the method:
public function index()
{
$inputs = Input::all();
$custom = Custom::findOrNew($inputs['pk']);
$custom->$inputs['name'] = $inputs['value'];
return $custom->save();
}
I get the following error TokenMismatchException in VerifyCsrfToken.php line 46:
Also form looks like this:
{!! Form::open(['url' => 'employees/update/' .$emp->id, 'class' => 'form-horizontal']) !!}
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" id="_token" class="hidden" data-token="">
<div class="form-group {!! $errors->has('first_name') ? 'has-error' : '' !!}">
<div class="col-sm-2" id="editable" data-type="text" data-placement="top" data-type='text' data-url='{{ URL::route('customFields') }}' data-pk="{{ $emp->id }}">Name</div>
<div class="col-lg-3">
<input type="text" name="first_name" class="form-control" value="{!! $emp->first_name !!}">
</div>
<div class="col-lg-3">
<input type="text" name="last_name" class="form-control" value="{!! $emp->last_name !!}">
</div>
<div class="col-md-4">
{!! $errors->first('first_name', '<span class="help-block">The name fields are required.</span>') !!}
</div>
</div>
{!! Form::close() !!}
And this is the JS for it:
$(document).ready(function() {
//toggle `popup` / `inline` mode
$.fn.editable.defaults.mode = 'inline';
//make editable
$('#editable').editable();
});
Anyone know how to get around this?