I think I just hit a bug in 1.2.3 which did not exist in 1.2. The bug is duplicatable with CodeIgniter 2.1.0 and 2.1.1.
The problem is when I would like to use set_relation between a primary and secondary table and the field names in the primary and secondary tables are the same. In this situation the filed in the primary table (in the example racks.name) shows nothing in the gridview. In edit or add view everything is Ok. If the field names are not the same - everything is ok.
Here is the schema:
table racks:
[font=courier new,courier,monospace]CREATE TABLE IF NOT EXISTS `racks` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`room_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=170 ;[/font]
table rooms:
[font=courier new,courier,monospace]CREATE TABLE IF NOT EXISTS `rooms` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(128) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;[/font]
Here is the the php code:
function test() {
$this->_init_session();
$crud = new grocery_crud();
$crud->set_theme("datatables");
$crud->set_theme("flexigrid");
$crud->set_table("racks");
$crud->set_relation('room_id','rooms','name');
$crud->columns('name','room_id');
$crud->display_as('name','Rack Name');
$crud->display_as('room_id','Room');
$crud->set_subject("Rack",true);
$crud->order_by('id');
$output = $crud->render();
$this->_example_output($output);
}
Many thanks in advance for your help!
Regards,
Stefan