Saturday, February 17, 2018

x-editable error 419 in laravel - development

x-editable error 419 in laravel

I try to change value of my column in users table with x-editable and I get 419 error on network.

codes

here is my CONTROLLER

public function changeprimaryaddress(Request $request){
      try {
          $id = $request->input('pk');
          $field = $request->input('name');
          $value = $request->input('value');

          $user = User::findOrFail($id);
          $user->{$field} = $value;
          $user->save();
      } catch (Exception $e) {
          return response($e->getMessage(), 400);
}

my ROUTE

Route::post('/changeprimaryaddress','UserController@changeprimaryaddress')->name('changeprimaryaddress');

my HTML code

<a href="#"
class="change"
data-type="select"
data-name="address_id"
data-pk=""
data-value=""
data-title="Select New Primary Address"
data-url="">Change</a>

my JAVASCRIPT

<script type="text/javascript">
$(function() {
    $('.change').editable({
        source: [
            @foreach($addresses as $address)
                { value: '', text: ' - , , , ' }
                @unless ($loop->last)
                    ,
                @endunless
            @endforeach
        ]
    });
});
</script>

screenvideo

If you like to see the process and errors i provided small video you can see.

result

any idea why is that?



from Laravel Questions and Answers https://laravelquestions.com/php/x-editable-error-419-in-laravel/
via Lzo Media

No comments:

Post a Comment