diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 01f58ac1b987b69c95536e444079c092314734fa..bcf0503dd61ed463f5abfb2ea7f97833ad9d4440 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -191,8 +191,7 @@ class DynamicForm extends VerySimpleModel { $inst->save(); foreach ($ht['fields'] as $f) { $f = DynamicFormField::create($f); - $f->form_id = $inst->id; - $f->setForm($inst); + $f->form = $inst; $f->save(); } } @@ -391,11 +390,11 @@ Signal::connect('model.updated', Signal::connect('model.created', array('TicketForm', 'dropDynamicDataView'), 'DynamicFormField', - function($o) { return $o->getForm()->get('type') == 'T'; }); + function($o) { return $o->form->get('type') == 'T'; }); Signal::connect('model.deleted', array('TicketForm', 'dropDynamicDataView'), 'DynamicFormField', - function($o) { return $o->getForm()->get('type') == 'T'; }); + function($o) { return $o->form->get('type') == 'T'; }); // If the `name` column is in the dirty list, we would be renaming a // column. Delete the view instead. Signal::connect('model.updated', diff --git a/include/class.orm.php b/include/class.orm.php index 53ea936477c95464b25e66c737cf8222ab09af2d..e7e54d95e4b6e10c680cb1848aee668234bebed0 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -71,6 +71,8 @@ class VerySimpleModel { function set($field, $value) { // Update of foreign-key by assignment to model instance if (isset(static::$meta['joins'][$field])) { + if (!isset(static::$meta['joins'][$field]['fkey'])) + static::_inspect(); $j = static::$meta['joins'][$field]; if ($j['list'] && ($value instanceof InstrumentedList)) { // Magic list property diff --git a/scp/forms.php b/scp/forms.php index 3b7e6af04e7f137af5732a6d7866fb169fd2a495..9721c2f0055d5d29013965c0cf88170164e3fc1f 100644 --- a/scp/forms.php +++ b/scp/forms.php @@ -129,7 +129,7 @@ if($_POST) { $form->_dfields = $form->_fields = null; $form->save(true); foreach ($form_fields as $field) { - $field->set('form_id', $form->get('id')); + $field->form = $form; $field->save(); } // No longer adding a new form diff --git a/scp/lists.php b/scp/lists.php index 5247a0643c36e1aed9c9b8b73c6ff75661aa0dff..7ea71f39334d027016bfcc8fa67c433bf13fbbe8 100644 --- a/scp/lists.php +++ b/scp/lists.php @@ -117,6 +117,7 @@ if($_POST) { break; case 'add': if ($list=DynamicList::add($_POST, $errors)) { + $form = $list->getForm(); $msg = sprintf(__('Successfully added %s'), __('this custom list')); } elseif ($errors) { @@ -180,9 +181,10 @@ if($_POST) { 'type' => $_POST["type-new-$i"], 'name' => $_POST["name-new-$i"], )); - $field->setForm($form); - if ($field->isValid()) + if ($field->isValid()) { + $field->form = $form; $field->save(); + } else $errors["new-$i"] = $field->errors(); }