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 {
function addDynamicData($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();
return $entry;
......
......@@ -254,12 +254,12 @@ class User extends UserModel {
return $this->created;
}
function addForm($form, $sort=1) {
$form = $form->instanciate();
$form->set('sort', $sort);
$form->set('object_type', 'U');
$form->set('object_id', $this->getId());
$form->save();
function addForm($form, $sort=1, $data=null) {
$entry = $form->instanciate($sort, $data);
$entry->set('object_type', 'U');
$entry->set('object_id', $this->getId());
$entry->save();
return $entry;
}
function to_json() {
......@@ -292,14 +292,11 @@ class User extends UserModel {
}
function addDynamicData($data) {
$uf = UserForm::getNewInstance();
$uf->setClientId($this->id);
foreach ($uf->getFields() as $f)
if (isset($data[$f->get('name')]))
$uf->setAnswer($f->get('name'), $data[$f->get('name')]);
$uf->save();
return $uf;
$entry = $this->addForm(UserForm::objects()->one(), 1, $data);
// FIXME: For some reason, the second save here is required or the
// custom data is not properly saved
$entry->save();
return $entry;
}
function getDynamicData($create=true) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment