callbacks in MVC
public function test(){
$data = ORM::factory('testdata')->find_all();
Table::factory()
->set_b开发者_运维问答ody_data($data)
->set_row_titles('id')
->set_column_titles(Table::AUTO)
->set_callback('format_row', 'row')
->render(true);
$this->template->title = '';
$this->template->payment_content = '';
}
function format_row($row, $index){
if ($index % 2 == 0) return new Tr('', 'zebra');
}
// getting an error : callback function format_row does not exist!, both methods declared in a controller class (Payment_Controller)
how do I do callbacks in MVC?
If format_row()
also belongs to the class where the test()
method is, then the callback should be passed as array($this, 'format_row')
. So, perhaps you should change the line 7 of test()
to ->set_callback(array($this, 'format_row'), 'row')
.
精彩评论