Commit 33cac642 authored by Dries's avatar Dries
Browse files

- Patch #61952 by Matt: usability improvement: add auto-complete functionality...

- Patch #61952 by Matt: usability improvement: add auto-complete functionality on the profile configuration patch.
parent 0f7ed2a5
......@@ -66,6 +66,11 @@ function profile_menu($may_cache) {
'title' => t('add field'),
'callback' => 'profile_field_form',
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/settings/profile/autocomplete',
'title' => t('profile category autocomplete'),
'callback' => 'profile_admin_settings_autocomplete',
'access' => user_access('administer users'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/settings/profile/edit',
'title' => t('edit field'),
'callback' => 'profile_field_form',
......@@ -212,6 +217,7 @@ function profile_field_form($arg = NULL) {
$form['fields']['category'] = array('#type' => 'textfield',
'#title' => t('Category'),
'#default_value' => $edit['category'],
'#autocomplete_path' => 'admin/settings/profile/autocomplete',
'#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
'#required' => TRUE,
);
......@@ -786,3 +792,16 @@ function _profile_field_types($type = NULL) {
function _profile_field_serialize($type = NULL) {
return $type == 'date';
}
/**
* Retrieve a pipe delimited string of autocomplete suggestions for profile categories
*/
function profile_admin_settings_autocomplete($string) {
$matches = array();
$result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%s%%')", $string, 0, 10);
while ($data = db_fetch_object($result)) {
$matches[$data->category] = check_plain($data->category);
}
print drupal_to_js($matches);
exit();
}
......@@ -66,6 +66,11 @@ function profile_menu($may_cache) {
'title' => t('add field'),
'callback' => 'profile_field_form',
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/settings/profile/autocomplete',
'title' => t('profile category autocomplete'),
'callback' => 'profile_admin_settings_autocomplete',
'access' => user_access('administer users'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/settings/profile/edit',
'title' => t('edit field'),
'callback' => 'profile_field_form',
......@@ -212,6 +217,7 @@ function profile_field_form($arg = NULL) {
$form['fields']['category'] = array('#type' => 'textfield',
'#title' => t('Category'),
'#default_value' => $edit['category'],
'#autocomplete_path' => 'admin/settings/profile/autocomplete',
'#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
'#required' => TRUE,
);
......@@ -786,3 +792,16 @@ function _profile_field_types($type = NULL) {
function _profile_field_serialize($type = NULL) {
return $type == 'date';
}
/**
* Retrieve a pipe delimited string of autocomplete suggestions for profile categories
*/
function profile_admin_settings_autocomplete($string) {
$matches = array();
$result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%s%%')", $string, 0, 10);
while ($data = db_fetch_object($result)) {
$matches[$data->category] = check_plain($data->category);
}
print drupal_to_js($matches);
exit();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment