Warning: Invalid argument supplied for foreach() in form_select_options() (line 2837 of includes/form.inc) I get the following erros on selecting the selectbox. 
Here onchang of this field will populate another checkbox with city details id zipcode using ajax callback.

 $zipcode_options = get_all_zipcodes_ascending();

  // Populate Ort on auktion clone. 
  $selected = isset($auktion-&gt;zip_code) ? $auktion-&gt;zip_code : NULL;
  $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected;
  $ort_options = _ajax_city_dropdown_options($selected);

  $form['zip_code'] = [
    '#type' =&gt; 'select',
    '#title' =&gt; t('PLZ'),
    '#options' =&gt; $zipcode_options,
    '#default_value' =&gt; isset($auktion-&gt;zip_code) ? $auktion-&gt;zip_code : "",
    '#select2' =&gt; ['width' =&gt; '100%', 'placeholder' =&gt; t('Enter a zipcode'), 'allowClear' =&gt; TRUE],
    '#empty_option' =&gt; '',
    '#validated' =&gt; TRUE,
    '#required' =&gt; TRUE,
    '#ajax' =&gt; array(
      'event' =&gt; 'change',
      'callback' =&gt; 'ajax_example_dependent_dropdown_callback',
      'wrapper' =&gt; 'dropdown-second-replace',
    ),
  ];


Referenced many links but cannot find a solution to resolve this issue.

References:

https://www.drupal.org/node/586576

populate drop down from results using ajax

http://techqa.info/drupal/question/203725/help-understand/solve-this-warning:-invalid-argument-supplied-for-foreach%28%29-in-views-that-requires-class-registry-clean-to-mend
Looking on the code i suspect  that error lies in these lines-
$selected = isset($auktion-&gt;zip_code) ? $auktion-&gt;zip_code : NULL;
 $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected;
$ort_options = _ajax_city_dropdown_options($selected);

And according to my understanding adding these lines will fix this warning-

 $selected = isset($auktion-&gt;zip_code) ? $auktion-&gt;zip_code : NULL;
$selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected;
$ort_options = _ajax_city_dropdown_options($selected);
if(!is_array($ort_options)){
    $ort_options=array();
}


Assuming that _ajax_city_dropdown_options($selected); returns options for second select list/ Check Boxes there can be some options in first Select List or there is none selected in first list for which there is no values available for second list. So returning an empty array will address this situation and prevent this error form appearing.