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. /*
  4. bug in _form_builder_handle_input_element() function in form.inc at line when doing "$form['#attributes']['disabled'] = 'disable';"
  5. Fatal error: Cannot use string offset as an array in /data/projects/voip_support/trunk/control_interface/includes/form.inc on line 965
  6.  
  7. */
  8.  
  9.  
  10. function user_queue_member_admin($form, $form_state = NULL) {
  11.   if(module_exists("profile")) {
  12.     $default_value = FALSE;
  13.     if($field = _user_queue_member_get_profile_field()) {
  14.       $default_value = $field->name." [".$field->fid."]";
  15.     }
  16.     $form["profile_field"] = array(
  17.       "#type" => "textfield"
  18.       ,"#title" => t("Phone number field")
  19.       ,"#autocomplete_path" => "admin/user/user_queue_member/autocomplete"
  20.       ,"#required" => FALSE
  21.       ,"#default_value" => $default_value
  22.     );
  23.   } else {
  24.     $form["profile_field"] = array(
  25.       "#value" => t("Enable profile module to send calls to user phone number.")
  26.       ,"#title" => t("Phone number field")
  27.     );
  28.   }
  29.   $form["save"] = array(
  30.     "#type" => "submit"
  31.     ,"#value" => "Save"
  32.   );
  33.   return $form;
  34. }
  35.  
  36. function user_queue_member_admin_validate($form, &$form_state) {
  37.   if($form_state["values"]["profile_field"]) {
  38.     /* parse the profile field */
  39.     if(!preg_match("^.*\[([0-9]+)\]$", $form_state["profile_field"], $matches)) {
  40.       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.");
  41.       return;
  42.     }
  43.     /* see if the fid exists */
  44.     if(!$field = db_fetch_object(db_query('SELECT f.name, f.fid FROM {profile_fields} f WHERE f.fid = %d', $matches[1]))) {
  45.       form_error($form["profile_field"], "Profile field does not exist, you can keep it blank if you do not want to use phone number.");
  46.       return;
  47.     }
  48.     $form_state["fid"] = $field->fid;
  49.   }
  50. }
  51.  
  52. function user_queue_member_admin_submit($form, &$form_state) {
  53.   if($form_submit["fid"]) {
  54.       variable_set(USER_QUEUE_MEMBER_PHONE_NUMBER, $form_submit["fid"]);
  55.   }
  56. }
  57.  
  58. function user_queue_member_admin_autocomplete($string) {
  59.   $matches = array();
  60.   $result = db_query_range("SELECT f.name, f.fid FROM {profile_fields} AS f WHERE LOWER(f.name) LIKE LOWER('%s%%')", $string, 0, 10);
  61.   while ($data = db_fetch_object($result)) {
  62.     $matches[$data->name." [".$data->fid."]"] = check_plain($data->name);
  63.   }
  64.   drupal_json($matches);
  65. }