warning: Invalid argument supplied for foreach() in includes/form.inc on line 1207.

No idea how to obtain a stack trace.

Comments

tom_o_t’s picture

I see the same after upgrading to the latest dev release when editing or adding a preset.

The code that's throwing the error in form.inc is:

function form_type_checkboxes_value($form, $edit = FALSE) {
  if ($edit === FALSE) {
    $value = array();
    $form += array('#default_value' => array());
    foreach ($form['#default_value'] as $key) {
      $value[$key] = 1;
    }
    return $value;
  }
  elseif (!isset($edit)) {
    return array();
  }
}

I've not got a proper debugger set up on my new machine, but if there's no follow up on this issue I guess that will be motivation for me!

tom_o_t’s picture

OK - it's the options_form for the tooltip and popups - defaults are NULL.

I tried removing the #default_value if it's not set (instead of setting it to NULL). This removed the errors, but caused other errors upon saving.

includes/behaviors/openlayers_behavior_popup.inc


  /**
   * Form defintion for per map customizations.
   */
  function options_form($defaults) {
    // Only prompt for vector layers
    $vector_layers = array();
    foreach ($this->map['layers'] as $id => $name) {
      $layer = openlayers_layer_load($id);
      if (isset($layer->data['vector']) && $layer->data['vector'] == TRUE) {
        $vector_layers[$id] = $name;
      }
    }
    $options = array();
    $options = array(
      'layers' => array(
        '#title' => t('Layers'),
        '#type' => 'checkboxes',
        '#options' => $vector_layers,
        '#description' => t('Select layer to apply popups to.')
      ),
    );
    if (isset($defaults['layers'])) {
      $options['#default_value'] = $defaults['layers'];
    }
    return $options;
  }
gmclelland’s picture

FYI... I am getting this as well.

zzolo’s picture

Status: Active » Fixed

Fixed in http://drupal.org/cvs?commit=387980 (note forgot # in commit message)

strk’s picture

confirmed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.