Fix for bug in _form_builder_handle_input_element() function in form.inc ..

  1. <?php # vim: set filetype=php expandtab tabstop=2 shiftwidth=2 autoindent smartindent:
  2.  
  3. function user_queue_member_admin($form, $form_state = NULL) {
  4.   if(module_exists("profile")) {
  5.     $default_value = FALSE;
  6.     if($field = _user_queue_member_get_profile_field()) {
  7.       $default_value = $field->name." [".$field->fid."]";
  8.     }
  9.     $form["profile_field"] = array(
  10.       "#type" => "textfield"
  11.       ,"#title" => t("Phone number field")
  12.       ,"#autocomplete_path" => "admin/user/user_queue_member/autocomplete"
  13.       ,"#required" => FALSE
  14.       ,"#default_value" => $default_value
  15.     );
  16.   } else {
  17.     $form["profile_field"] = array(
  18.       "#title" => t("Phone number field")
  19.       ,"#value" => t("Enable profile module to send calls to user phone number.")
  20.     );
  21.   }
  22.   $form["save"] = array(
  23.     "#type" => "submit"
  24.     ,"#value" => "Save"
  25.   );
  26.   return $form;
  27. }
  28.  
  29. function user_queue_member_admin_validate($form, &$form_state) {
  30.   die();
  31.   if($form_state["values"]["profile_field"]) {
  32.     /* parse the profile field */
  33.     if(!preg_match("^.*\[([0-9]+)\]$", $form_state["profile_field"], $matches)) {
  34.       form_error($form["profile_field"], "Profile field could not be identified, you can keep it blank if you do not want to use phone number.");
  35.       return;
  36.     }
  37.     /* see if the fid exists */
  38.     if(!$field = db_fetch_object(db_query('SELECT f.name, f.fid FROM {profile_fields} f WHERE f.fid = %d', $matches[1]))) {
  39.       form_error($form["profile_field"], "Profile field does not exist, you can keep it blank if you do not want to use phone number.");
  40.       return;
  41.     }
  42.     $form_state["fid"] = $field->fid;
  43.   }
  44. }
  45.  
  46. function user_queue_member_admin_submit($form, &$form_state) {
  47.   die();
  48.   if($form_submit["fid"]) {
  49.       variable_set(USER_QUEUE_MEMBER_PHONE_NUMBER, $form_submit["fid"]);
  50.   }
  51. }
  52.  
  53. function user_queue_member_admin_autocomplete($string) {
  54.   $matches = array();
  55.   $result = db_query_range("SELECT f.name, f.fid FROM {profile_fields} AS f WHERE LOWER(f.name) LIKE LOWER('%s%%')", $string, 0, 10);
  56.   while ($data = db_fetch_object($result)) {
  57.     $matches[$data->name." [".$data->fid."]"] = check_plain($data->name);
  58.   }
  59.   drupal_json($matches);
  60. }