diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 0045b6a430e3d864d4b8792df143a187214451fe..8c78c09b0cabfb1cfa563dd025e75350504b06ae 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -494,7 +494,7 @@ class DynamicFormEntry extends VerySimpleModel { function getForm() { if (!isset($this->_form)) { $this->_form = DynamicForm::lookup($this->get('form_id')); - if ($this->id) + if (isset($this->id)) $this->_form->data($this); } return $this->_form; diff --git a/include/class.orm.php b/include/class.orm.php index 289ddaef7d8003640e7f24a35d459781bb72c2e4..cdf25599501b82e474893d2ccca18823804d38f1 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -16,6 +16,8 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ +class OrmException extends Exception {} + class VerySimpleModel { static $meta = array( 'table' => false, @@ -46,6 +48,13 @@ class VerySimpleModel { $v = $this->ht[$field] = $class::lookup($this->ht[$j['local']]); return $v; } + throw new OrmException(sprintf('%s: %s: Field not defined', + get_class($this), $field)); + } + + function __isset($field) { + return array_key_exists($field, $this->ht) + || isset(static::$meta['joins'][$field]); } function set($field, $value) { @@ -86,7 +95,8 @@ class VerySimpleModel { // Construct related lists if (isset(static::$meta['joins'])) { foreach (static::$meta['joins'] as $name => $j) { - if (isset($j['list']) && $j['list']) { + if (isset($this->{$j['local']}) + && isset($j['list']) && $j['list']) { $fkey = $j['fkey']; $this->{$name} = new InstrumentedList( // Send Model, Foriegn-Field, Local-Id