CI Ignited-Datatables, wrong variable returning - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7) +--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13) +--- Thread: CI Ignited-Datatables, wrong variable returning (/showthread.php?tid=63946) |
CI Ignited-Datatables, wrong variable returning - mr.web - 12-26-2015 Hi, I'm using version 1.15 of the Ignited-Datatables to get data to JS Datatables using Ajax. The problem I'm having is with the `edit_column` and `add_column` functions. They are using a `$1` to get the variables inside the functions, like so: Code: edit_column('stato', renderStato('$1'), 'stato') Code: if(!function_exists('renderStato')){ Looks like the $1 variable is not getting validated correctly, as $1 is set to 1 but the library sees it as $1, so is never true. How can I fix this? RE: CI Ignited-Datatables, wrong variable returning - Tim Brownlaw - 12-26-2015 I think you have misinterpreted what they have done... What you are doing is passing in a string instead of a variable as your parameter to the function renderStato(). As you have seen, it is passing in the literal string $1 as you have surrounded it in single quotes. Stock standard PHP Programming rules apply, if you wrap anything in single quotes - it's the literal string. If you wrap a variable in double quotes - then it gets evaluated ( Big difference ) But in your case you do not need either. So your call... PHP Code: edit_column('stato', renderStato('$1'), 'stato'); PHP Code: edit_column('stato', renderStato($1), 'stato'); AND please do not use variable names like $1, that is a Huge NO NO! Rule of thumb: "Name a Variable What it is", even if it's a little long winded. RE: CI Ignited-Datatables, wrong variable returning - RWCH - 03-10-2016 I wrote a tutorial how to integrate DataTables and Editor in CodeIgniter 3. Maybe it is of any help to you, see http://ci.dubbel16.nl |