In case you've missed it, you are looking at an older version of the website. Checkout our latest version, we promise you will love it 😍

callback_column

void callback_column( string $column , mixed $callback ) 
Quick Description: This callback runs on each row. It escapes the auto column value and runs the callback.

This callback runs on each row. It escapes the auto column value and runs the callback. For this callback the return value is required and must be a string. The parameters that callback takes are : 1 - the primary key value of the row and 2 - the row as an object. The row as an object we can use it if we want quickly to take a value for another field.

Example:

 
public function webpages()
{
  $c = new grocery_CRUD();
 
  $c->set_table('webpages');
  $c->order_by('priority');
  $c->set_subject('Webpage');
  $c->columns('menu_title','url','status','priority');
 
  $c->callback_column('menu_title',array($this,'_callback_webpage_url'));
 
  $output = $c->render();
  $this->_view_output($output);
}
 
public function _callback_webpage_url($value, $row)
{
  return "<a href='".site_url('admin/sub_webpages/'.$row->id)."'>$value</a>";
}