Hello,
Is there a possibility to use a user-view ? I can use node-view in the webform component, but I would like to refer user. How can I do ?
Thanks if help !

ALzh

Comments

lavamind’s picture

Subscribe.

robbyvanelderen’s picture

Same problem here, is there a sollution??

Thanks

lavamind’s picture

I found a way to do this, using a custom module and an autocomplete callback.

On the webform, create a textfield and note the textfield name as well as the webform node id.

In the custom module :

function mymodule_form_webform_client_form_<node>_alter(&$form, &$form_state) {
  $form['submitted']['<textfield>']['#autocomplete_path'] = 'autocomplete/users';
}

function mymodule_menu() {
  $items['autocomplete/users'] = array(
    'page callback' => '_mymodule_autocomplete_users',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
  );
  return $items;
}

function _mymodule_autocomplete_users($string) {
  $matches = array();
  $query = "SELECT u.name FROM {users} u WHERE name LIKE LOWER('%s%%')";
  $result = db_query_range($query, $string, 0, 10);
  while ($user = db_fetch_object($result)) {
    $matches[$user->name] = $user->name;
  }
  print drupal_to_js($matches);
  exit();
}

Replace <node> and <textfield> with the appropriate node id and textfield id.

That will give you autocomplete on usernames. If you also need autocomplete on profile values, you need a more complex query that does a join with the profile_values table.

westie’s picture

lavamind thank you for posting this, I had to make some minor changes but works very well!

trevorbradley’s picture

:( I came here with the autocomplete solution in hand, hoping to get a user multiple checkbox solution. Still hoping that it's an option in the future.

freakalis’s picture

Status: Active » Closed (works as designed)

You can reference users by using a User view.