1

In Drupal Commons, we're using the Realnames module. Is there a way to extend this module's information to other search box fields?

For example in the Organic Groups invite (/og/users/??/invite), could my users search for other users by the user's first or last name? That is, in the form og_invite_link_invite_page_form's first field (edit-invitees), how could I search on an individual's Given Name (first name) or Family Name (last name)?

This addition provided what I needed. Basically, I needed to override the $form['invitees'] by using and slighly modifying og_username_helper.module ( http://drupal.org/project/og_username_helper ).

 74     if ($form['#id'] == 'og-invite-link-invite-page-form') {
 75       // print 'in';
 76       // print_r($form['invitees']);
 77       
 78       $form['invitees'] = array(
 79           '#type' => 'textfield',
 80           '#description' => t('Lookup a username and add it to the list below.'),
 81           '#autocomplete_path' => 'og/username_helper/autocomplete',
 82           '#size' => 40,
 83           '#maxlength' => 60,
 84           '#weight' => -2,
 85           '#access' => $helper_access,
 86           );
 87 
 88       return $form;
 89     }
 90 
5
  • Update: I'm trying drupal.org/project/og_username_helper based on drupal.org/node/677568#comment-3251108
    – Rick
    May 7, 2012 at 18:16
  • In the future, instead of editing your question, you should answer your own question and then mark that answer as accepted. Drupal Answers encourages you to answer your own questions when you find the answer; this helps future users who may have the same question that you did. May 7, 2012 at 23:53
  • Hi Patrick, I do not have enough reputation to answer my own question. I would love to have mark the above as a possible solution and get comment. I completely agree with you.
    – Rick
    May 8, 2012 at 15:07
  • Sorry, I didn't realize there was a reputation requirement for that. May 8, 2012 at 15:10
  • No worries. In fact, by asking another question I am able to post this below. My second question just pushed me over the line. Yay.
    – Rick
    May 8, 2012 at 16:57

1 Answer 1

1

I've packaged this up into a module to extend the og_username_helper.

 58 /**
 59  * Extends og_username_helper to Groups Invite Members tab
 60  */
 61 function soc_searchtweak_form_alter(&$form, $form_state, $form_id) {
 62 
 63   $form_changes = array();
 64   $form_changes['og-invite-link-invite-page-form']='invitees';
 65   $form_changes['commons-profile-friend-search-form']='search_text';
 66 
 67 
 68   foreach ($form_changes as $form_id=>$field_id) {
 69 
 70 
 71     if ($form['#id'] == $form_id) {
 72       $form[$field_id] = array(
 73           '#type' => 'textfield',
 74           '#description' => t('Lookup a username and add it to the list below.'),
 75           '#autocomplete_path' => 'og/username_helper/autocomplete',
 76           '#size' => 40,
 77           '#maxlength' => 60,
 78           '#weight' => -2,
 79           '#access' => $helper_access,
 80           );
 81 
 82       return $form;
 83     }
 84 
 85   }
 86 
 87 
 88 }

The module.info file puts og_username_helper as a dependency.

1 name = Search Tweak
2 description = Extends og_uesrname_helper in various places
3 core = 6.x
4 
5 
6 dependencies[] = og_username_helper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.