Skip to content
Snippets Groups Projects
Commit 8fade3a9 authored by Jared Hancock's avatar Jared Hancock
Browse files

users: Fix saving of custom data on new user

parent 3ca00167
No related branches found
No related tags found
No related merge requests found
...@@ -106,6 +106,8 @@ class Organization extends OrganizationModel { ...@@ -106,6 +106,8 @@ class Organization extends OrganizationModel {
function addDynamicData($data) { function addDynamicData($data) {
$entry = $this->addForm(OrganizationForm::objects()->one(), 1, $data); $entry = $this->addForm(OrganizationForm::objects()->one(), 1, $data);
// FIXME: For some reason, the second save here is required or the
// custom data is not properly saved
$entry->save(); $entry->save();
return $entry; return $entry;
......
...@@ -254,12 +254,12 @@ class User extends UserModel { ...@@ -254,12 +254,12 @@ class User extends UserModel {
return $this->created; return $this->created;
} }
function addForm($form, $sort=1) { function addForm($form, $sort=1, $data=null) {
$form = $form->instanciate(); $entry = $form->instanciate($sort, $data);
$form->set('sort', $sort); $entry->set('object_type', 'U');
$form->set('object_type', 'U'); $entry->set('object_id', $this->getId());
$form->set('object_id', $this->getId()); $entry->save();
$form->save(); return $entry;
} }
function to_json() { function to_json() {
...@@ -292,14 +292,11 @@ class User extends UserModel { ...@@ -292,14 +292,11 @@ class User extends UserModel {
} }
function addDynamicData($data) { function addDynamicData($data) {
$uf = UserForm::getNewInstance(); $entry = $this->addForm(UserForm::objects()->one(), 1, $data);
$uf->setClientId($this->id); // FIXME: For some reason, the second save here is required or the
foreach ($uf->getFields() as $f) // custom data is not properly saved
if (isset($data[$f->get('name')])) $entry->save();
$uf->setAnswer($f->get('name'), $data[$f->get('name')]); return $entry;
$uf->save();
return $uf;
} }
function getDynamicData($create=true) { function getDynamicData($create=true) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment