I'm trying to learn how to use addRef.
I think I need a way to tell addRef which field should link with 'id' in Master?
To test, I have a 'master' table:
<?php
class Model_TestMaster extends Model_Table {
public $table='testmaster';
function init(){
parent::init();
$this->addField('Description');
$this->hasMany('testslave');
}
}
and a 'slave' table:
<?php
class Model_TestSlave extends Model_Table {
public $table='testslave';
function init(){
parent::init();
$this->addField('MastersID');
$this->addField('SubDescription');
}
}
and then I set up the 'page' like this:
<?php
class page_test extends Page {
function init(){
parent::init();
$page=$this;
$tabs = $this->add('Tabs');
$crud = $tabs->addTab('Master')->add('CRUD');
$crud->setModel('testmaster');
if (! $crud->isEditing()) {
// add subCRUD
$sub_crud = $crud->addRef('testslave', array(
'extra_fields' => array('MastersID','SubDescription')));
}
}
I think I need a way to tell addRef which field should link with 'id' in Master?
It displays Ok, but when I press the button to expand the slave I get:
Application Error: Child element not found
BaseException, code: 0
Additional information:
Raised by object: Object Model_TestSlave(51cf4a73__ter_testslave_model_testslave)
element: testmaster_id
:
Stack trace:
File Object Name Stack Trace
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/BaseException.php :63 BaseException BaseException->collectBasicData(Null)
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/AbstractObject.php :545 BaseException BaseException->__construct("Child element not found", Null)
/ : 51cf4a73__ter_testslave_model_testslave Model_TestSlave->exception("Child element not found")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib\SQL/Model.php :107 Loggercall_user_func_array(Array(2), Array(1))
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/AbstractObject.php :331 51cf4a73__ter_testslave_model_testslave Model_TestSlave->exception("Child element not found")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib\SQL/Model.php :275 51cf4a73__ter_testslave_model_testslave Model_TestSlave->getElement("testmaster_id")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib\SQL/Many.php :79 51cf4a73__ter_testslave_model_testslave Model_TestSlave->addCondition("testmaster_id", "0000000001")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib\SQL/Model.php :248 51cf4a73__ter_testslave SQL_Many->ref(Null)
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib\View/CRUD.php :316 asol_Test_tabs_view_htmlelement_crud_model_testmaster Model_TestMaster->ref("testslave")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\page/test.php :15 asol_Test_tabs_view_htmlelement_crud CRUD->addRef("testslave", Array(1))
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/AbstractObject.php :306 asol_Test page_test->init()
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/ApiFrontend.php :130 asol Admin->add("page_Test", "Test", "Content")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/ApiWeb.php :428 asol Admin->layout_Content()
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/ApiFrontend.php :39 asol Admin->addLayout("Content")
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\atk4\lib/ApiWeb.php :275 asol Admin->initLayout()
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb/index.php :15 asol Admin->main()
Thank you,
Mark