How to add Form into the CompleteLister ATK4

118 Views Asked by At

I want to add a simple form to each row of CompleteLister. I've tried this:

<?php
class page_list extends Page {
    function init(){
        parent::init();

        $l = $this->add('Lister_Comment',null,'comm_list_spot','comm_list_spot');
        $l->setModel('Comment');
    }
    function defaultTemplate(){
        return array('view/comment_list');
    }
}
class Lister_Comment extends CompleteLister {
    function formatRow(){
        parent::formatRow();

        $f = $this->add('Form');
        $f->addField('line','com_text');
        $f->addSubmit();
        $this->current_row_html['commm'] = $f->getHTML();
    }

}
?>

` But it doesn't work. What I do wrong?

Thank you.

1

There are 1 best solutions below

0
On

Form is a delicate view and it needs to be sitting properly in a render tree. Here is how you could implement this better:

  1. manually iterate through model
  2. inside iteration, add a view with the content of your lister's row
  3. add a new form inside the comm tag by using 3rd argument of add()

This should work much better.