Child Element Not Found issue

90 views
Skip to first unread message

The Black Pig

unread,
Nov 15, 2012, 4:50:28 AM11/15/12
to agile-too...@googlegroups.com
Hi,

I am trying to implement the solution offered my Romans here.

I am getting the following error:

BaseException

Child element not found

Additional information:

  • Raised by object: Object Model_Tools(enjouanissonoffice_tools_model_tools)
  • element: Notes

Possible Actions:

:

Stack trace:
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/BaseException.php:38 BaseExceptionBaseException->collectBasicData(Null, Null, Null)
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/AbstractObject.php:300 BaseExceptionBaseException->__construct("Child element not found", Null, Null, Null)
/: enjouanissonoffice_tools_model_toolsModel_Tools->exception("Child element not found")
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/Model/Table.php:94 Loggercall_user_func_array(Array(2), Array(1))
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/AbstractObject.php:210 enjouanissonoffice_tools_model_toolsModel_Tools->exception("Child element not found")
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/Model/Table.php:229 enjouanissonoffice_tools_model_toolsModel_Tools->getElement("Notes")
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/page/tools.php:9 enjouanissonoffice_tools_model_toolsModel_Tools->ref("Notes")
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/AbstractObject.php:197 enjouanissonoffice_toolspage_tools->init()
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/ApiFrontend.php:122 enjouanissonofficeFrontend->add("page_tools", "tools", "Content")
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/ApiWeb.php:399 enjouanissonofficeFrontend->layout_Content()
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/ApiFrontend.php:37 enjouanissonofficeFrontend->addLayout("Content")
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/atk4/lib/ApiWeb.php:271 enjouanissonofficeFrontend->initLayout()
/Volumes/Data/Work/Black Pig/Enjouanisson/Office/index.php:15 enjouanissonofficeFrontend->main()

I have set up the Notes_Controller as per the initial post:

class Controller_Notes extends AbstractController {
    function init(){
        parent::init();

        $j=$this->owner->join("objects");
        $j->addField("note_count");

        $this->owner->hasMany("Notes","id","object_id"); //Model,model_id,our_id

        $this->owner->addMethod("refNotes",$this);
    }
}



This is my page class where the error occurs:

class page_tools extends Page {
    function init(){
        parent::init();

        $fields['grid'] = array('name', 'type', 'purchase_dt','current_hrs');
        $fields['edit'] = array('type', 'name', 'purchase_dt','purchase_hrs','current_hrs','purchase_price','purchase_from','disposal_dt');

        $m = $this->add('Model_Tools')->ref('Notes');

   $crud = $this->add('CRUD');
        $crud->setModel($m,$fields['edit'],$fields['grid']);
        $crud->grid->addColumn('Expander','Notes');

    }
}


and these are the model classes:

class Model_Tools extends Model_Table
{
    public $table="tools";

    function init(){
        parent::init();

        $err = "This is a reqired field";

        $this->addField('name')->mandatory($err);
        $this->addField('type')->listData(array('t'=>'Tractor','e'=>'Equipment'));
        $this->addField('purchase_dt')->type('date');
        $this->addField('purchase_hrs')->type('number');
        $this->addField('current_hrs')->type('number');
        $this->addField('purchase_price')->type('number');
        $this->addField('purchased_from_id');
        $this->addField('disposal_dt')->type('date');

        $this->hasOne('Object','object_id')->type('system');

    }
}

class Model_Notes extends Model_Table
{
    public $table="notes";

    function init(){
        parent::init();

        $err = "This is a reqired field";

        $this->addField('name')->mandatory($err);
        $this->addField('type')->listData(array('t'=>'Tractor','e'=>'Equipment'));
        $this->addField('date')->type('date')->defaultValue(date('Y-m-d'));
        $this->addField('blurb')->type('text');

        $this->setOrder('date','desc');
        
    }
}


Currently there are 2 rows in the 'tools' table with object_id's set and their respective entries in the 'objects' table.  There are no 'notes' yet.

Can anyone shed some light as to what's going wrong here?

Thanks
BP

Imants Horsts

unread,
Nov 15, 2012, 1:40:34 PM11/15/12
to agile-too...@googlegroups.com
I have not read all this topic due to limited time lately, but in short I guess you have to add Controller to your Model_Tools.
$this->add('Controller_Notes'); // put it in Model_Tools init() method
Reply all
Reply to author
Forward
0 new messages