1
I created in codeigniter a helper for datatable that would return an html with a bootstrap icon.
Follows the function:
function trata_check($valor)
{
$ci= & get_instance();
if($valor=='S'){
$html='<span class="glyphicon glyphicon-ok"></span>';
}
else{
$html='<span class="glyphicon glyphicon-remove"></span>';
}
return $html;
}
The part that calls the function in the controller is this:
->edit_column('diario', trata_check('$1'),'diario')
The problem is that the comparison if($valor=='S')
not being done, it is always returning false, but when I send only return the parameter passed it returns the right value, which can only be S
or N
.
The problem is how you are calling the helper, because what you are going through is the string '$1', not the value of the $1 variable.
– Yure Pereira
To pass the value use double quotes, treat_check("$1")
– Yure Pereira
Na can be the form that is passing the parameter inside the function? you are using simple quotes, therefore what will be passed would be the value $1 and not the variable value
– Bulfaitelo
The value is being passed yes, so much so that if I had it just return the value it returns normal, the problem is in the comparison. Anyway, I tried the suggestion and it wasn’t.
– Ruben Henrique Lima
Where do you see the $1?
– Yure Pereira
It is used to pass parameters in the edit_colum function of the CI.
– Ruben Henrique Lima