I have these two tables in the database:
Subservices:
id, ..., background_id
Backgrounds:
id, filename
With grocery crud I'd like to show the background thumbnail (which is the "filename" field) in a column of subservices.
In the controller I have this:
function index()
{
$crud = new grocery_CRUD();
...
$crud->columns('service_id', 'name','english_name', 'italian_text', 'english_text',
'background_id');
...
$crud->set_relation('background_id', 'backgrounds', 'filename');
$crud->callback_column('background_id', array($this, 'show_picture_in_row'));
...
}
function show_picture_in_row($id, $row)
{
$string = '<img src="images/backgrounds/thumbs/'.$row->filename.'" />';
return $string;
}
It's not working. It just displays the filename, for example: picture_1.jpg
What am I doing wrong?