Using X-editable with CodeIgniter 3 CSRF issue |
I'm using CodeIgniter 3 with CSRF enabled. I have a page that is using X-editable library http://vitalets.github.io/x-editable/index.html to do inline editing on that page.
Has anyone used X-editable with CodeIgniter and CSRF turned on? My issue is when I have CSRF enabled I get the following CodeIgniter generated error: <h1>An Error Was Encountered</h1> <p>The action you have requested is not allowed.</p> It works fine if I disable CSRF in CI. What I do know is that I can't figure out a way to add a hidden field with the CSRF token when using the X-editable library, because the javascript library adds it's own form and form fields. I know that CI's open_form() method adds the hidden field with the CSRF token automatically, but I have no option to use that with this particular library. Any ideas? I have been stuck on this for a few days now. This is the config.php file in my CI project $config['csrf_protection'] = TRUE; $config['csrf_token_name'] = 'mycsrfname'; $config['csrf_cookie_name'] = 'csrfcookiename'; $config['csrf_expire'] = 7200; $config['csrf_regenerate'] = TRUE; $config['csrf_exclude_uris'] = array(); This is in the controller $name = $this->input->post('name'); $value = $this->input->post('value'); $pk = $this->input->post('pk'); $result = $this->garage_model->editItem($name,$value,$pk); |
Welcome Guest, Not a member yet? Register Sign In |