开发者

callbacks in MVC

开发者 https://www.devze.com 2022-12-10 07:40 出处:网络
public function test(){ $data = ORM::factory(\'testdata\')->find_all(); Table::factory() ->set_b开发者_运维问答ody_data($data)
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').

0

精彩评论

暂无评论...
验证码 换一张
取 消