Reputation: 1
This is my addColumn
function, to which I want to pass these two parameters, $result
and $filter_id
.
->addColumn('check_field', function ($result,$filter_fld) {
$check_fields = $filter_fld;
$check_field_arr = $this->createAarrayChackList($check_fields);
$status = in_array($result->id, $check_field_arr)==true ? 'checked' :'';
return '<input type="checkbox" class="chk itemName form-check-input" id="seasel" value="$data->id" name="origin_port" onclick="get_value_to_hidden_field();" '.$status.'>';
})
How can i pass the two parameters?
Upvotes: 0
Views: 98
Reputation: 13394
You are passing parameters to a function that be named closure.
A closure is a function that is evaluated in its own environment, which has one or more bound variables that can be accessed when the function is called.
The use() keyword let's you import variables from outside the function environment, inside the function.
->addColumn('check_field', function () use ($result, $filter_fld) {
...
})
Upvotes: 2