I need to create several callbacks for field formatting and need to do this dynamically as I don't know the exact FieldNames until runtime.
I can make everything in GC work except in the callback_field (or callback_edit or callback_add)
I think I just don't know PHP well enough to know how to get this coded right so it works.
Below is a simple hand-coded example.
What I need is for the VALUE of the $ded1 and $ded2 variables to be INSERTED into the input statement INSIDE the function.
In the sample code where you see ... name="'.$ded1.'" ... I need it to evaluate to ... name="Compression" ... for $ded1 and name="Marketing" for $ded2, etc.
Somehow because of the "function" Declaration, those two variables are not in scope and I can't seem to get this going?
The first 1/2 of each callback_field where the $ded1 and $ded2 are coded works fine, its the 2nd part where the "function" is declared is where it breaks.
What am I missing?
I am basically trying to do either this or to create the two callback functions dynamically in code, but I can't figure out how to do that either...
Any feedback appreciated.
Jean.
EXAMPLE CODE:
$ded1 = 'Compression';
$crud->callback_field($ded1, function ($value, $primary_key) {
return '<input type="numeric" maxlength="15" value="'.$value.'" name="'.$ded1.'" style="width:100px">';
});
$ded2 = 'Marketing';
$crud->callback_field($ded2, function ($value, $primary_key) {
return '<input type="numeric" maxlength="15" value="'.$value.'" name="'.$ded2.'" style="width:100px">';
});