⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Old documentation



Frontrider

Frontrider
  • profile picture
  • Member

Posted 22 March 2017 - 13:34 PM

I spent 2 days trying to figure my callbacks. I needed "external" (field name and stuff) data inside them, but I could not get them in.

Now for the real problem.

The documentation doesn't includes this as the template for the function:

$this->crud->callback_edit_field(table_name,function($value, $row, $field_info, $field_values)

The documentation only includes the first 2 parameters as valid, the rest was left out for some reason.
I figured it out, but, I would not have been able to do so, If I wasn't tracing back the function to actually add what I think I need (whitch would be bad practice).


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 26 March 2017 - 20:12 PM

Hello @Frontrider,

 

Have you considered to work with the use keyword? For example in your case you can do something like that:

$somethingOutside = 'test';

$this->crud->callback_edit_field(table_name, function($value, $row) use ($somethingOutside) {
    // You can now use the $somethingOutside variable here
});