ATK4 Fatal Error atk4\core\Exception: Attempting to initialize twice

70 views Asked by At

I am exploring the Atk4 UI. Below I am tried to use a View with several Table views (with array data), but the atk4 shows fatal error: Attempting to initialize twice.

$mainDiv = new \atk4\ui\View();
$table = new \atk4\ui\Table(['celled' => true]);
$table->setSource([['test'=>5]]);
$mainDiv->add($table);
$app->layout->add($mainDiv);

Is it a bug or am I doing something wrong?

1

There are 1 answers

1
romaninsh On

Trying your example as-is I got this error:

atk4\ui\Exception\NoRenderTree: You must use either add($obj) or $obj->init() before addColumn()

After adding $table->init() right before setSource() made example work. However for table to work you need to define columns.