diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php
index a86fd491..e6d5396c 100644
--- a/code/SecurityAdmin.php
+++ b/code/SecurityAdmin.php
@@ -275,6 +275,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$fieldName = $this->urlParams['ID'];
$fieldVal = $_REQUEST[$fieldName];
$result = '';
+ $uidField = Member::get_unique_identifier_field();
// Make sure we only autocomplete on keys that actually exist, and that we don't autocomplete on password
if(!singleton($this->stat('subitem_class'))->hasDatabaseField($fieldName) || $fieldName == 'Password') return;
@@ -286,11 +287,17 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
// If the current user doesnt have permissions on the target user,
// he's not allowed to add it to a group either: Don't include it in the suggestions.
if(!$match->canView() || !$match->canEdit()) continue;
-
- $data = $match->FirstName;
- $data .= ",$match->Surname";
- $data .= ",$match->Email";
- $result .= "
" . $match->$fieldName . "($match->FirstName $match->Surname, $match->Email)$data";
+
+ $data = array();
+ foreach($match->summaryFields() as $k => $v) {
+ $data[$k] = $match->$k;
+ }
+ $result .= sprintf(
+ '%s (%s)',
+ Convert::raw2att(Convert::raw2json($data)),
+ $match->$fieldName,
+ implode(',', array_values($data))
+ );
}
$result .= "";
return $result;
diff --git a/javascript/MemberTableField.js b/javascript/MemberTableField.js
index b66c891c..ed7805bd 100755
--- a/javascript/MemberTableField.js
+++ b/javascript/MemberTableField.js
@@ -77,18 +77,10 @@ AjaxMemberLookup = {
}
},
afterAutocomplete : function(field, selectedItem) {
- var data = selectedItem.getElementsByTagName('span')[1].innerHTML;
- var items = data.split(",");
- form = Element.ancestorOfType(field, 'form');
- // TODO more flexible column-detection
- form.elements.FirstName.value = items[0];
- form.elements.Surname.value = items[1];
- form.elements.Email.value = items[2];
- if(items[3] && form.elements.Password)
- form.elements.Password.value = items[3];
-
- //var fieldSet = field.parentNode.parentNode.getElementsByTagName('input');
- //ajaxSubmitFieldSet('admin/security/savemember?MemberBaseGroupID='.$('MemberBaseGroupID'), fieldSet);
+ var items = jQuery(selectedItem).data('fields'), form = jQuery(selectedItem).parents('form:first');
+ for(name in items) {
+ jQuery(form).find('input[name='+name+']').val(items[name]);
+ }
}
}