MVC callbacks

1 Cevap php
public function test(){
        $data = ORM::factory('testdata')->find_all();

        Table::factory()
            ->set_body_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');
    }

/ / Bir hata alıyorum:! Çağırma işlevi format_row yok, bir kontrolör sınıfta bildirilen iki yöntem (Payment_Controller)

Ben MVC callbacks nasıl yapacağız?

1 Cevap

format_row() da test() yöntemidir sınıfına ait ise, geri arama array($this, 'format_row') olarak kabul edilmelidir. Yani, belki de ->set_callback(array($this, 'format_row'), 'row') için test() satırını 7 değiştirmek gerekir.