CodeIgniter Forums

Full Version: flexigrid and CI 2.0.3 token
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hello all

I have sucess fully implemented flexigrid in CI 2.0.3 but when I tried to enbale CSRF=TRUE from config file my Flexigrid is not working.

Can anyone please help me to solve this

I found following alternatives but its not working.please help me


In order to work with CSRF plugin (http://ellislab.com/forums/
viewthread/92399/)
I have added a line in helper and flexigrid.js which are;
flexigrid_helper.php
46. $grid_js .= "sortorder: '".$sortorder."',";
47. $grid_js .= "ci_token: '".getCSRFToken()."',";
and flexigrid.js
51. onSuccess: false,
52. ci_token: '',
52. onSubmit: false

Its not working for me.I think getCSRFToken() is not available in CI 2.0.3.please help me

El Forum

[eluser]Unknown[/eluser]
OK Here is the solution:
in flexigrid_helper.php put:
$grid_js .= "<name of your token from config.php>: '".$CI->security->get_csrf_hash()."',";
At about line 50.
Then in flexigrid.js put:
onChangeSort: false,
onSuccess: false,
<name of your token from config.php> : '',
onError: false,
onSubmit: false //using a custom populate function
}, p);
At about line 45-50.
Then further down in flexigrid.js put:
{
name: 'query',
value: p.query
}, {
name: 'qtype',
value: p.qtype
}, {
name: '<name of your token from config.php> ',
value: p.<name of your token from config.php>
}];
if (p.params) {
for (var pi = 0; pi < p.params.length; pi++) {
param[param.length] = p.params[pi];
}
}
At about line 520-530
This will add the csrf token with the right parameter name to json request sent by flexigrid.