Problems with form api and #tree I'm trying to create a form element with an array of child inputs. How is the below example incorrect in D7, I'm getting this error:

Fatal error: Cannot create references to/from string offsets nor overloaded objects in C:\wamp\www\water-uk\www\includes\common.inc on line 6518

array(3) {
  '#tree' =&gt;
  bool(true)
  '#type' =&gt;
  string(8) "fieldset"
  'first' =&gt;
  array(6) {
    '#type' =&gt;
    string(6) "select"
    '#options' =&gt;
    array(8) {
      'All' =&gt;
      string(8) "Show all"
      [0] =&gt;
      class stdClass#470 (1) {
        ...
      }
      [1] =&gt;
      class stdClass#468 (1) {
        ...
      }
      [2] =&gt;
      class stdClass#469 (1) {
        ...
      }
    }
    '#size' =&gt;
    NULL
    '#default_value' =&gt;
    string(3) "All"
    '#ajax' =&gt;
    array(5) {
      'callback' =&gt;
      string(38) "_listing_blocks_select_tax_depth_js"
      'wrapper' =&gt;
      string(18) "tax-select-wrapper"
      'method' =&gt;
      string(6) "append"
      'effect' =&gt;
      string(4) "fade"
      'event' =&gt;
      string(6) "change"
    }
    '#required' =&gt;
    bool(false)
  }
}
You appear to be using stdClass objects for the values in your options array. Drupal expects a string for each of the options.

You probably have code like:

foreach ($something as $item) {
  // $item is a stdClass.
  $options[$item-&gt;key] = $item;
}


when you need to have something like

foreach ($something as $item) {
  // $item is a stdClass.
  $options[$item-&gt;key] = $item-&gt;name;
}