warning: array_merge() [function.array-merge]: Argument #1 is not an array in .../modules/contrib/tax_by_taxo/tax_by_taxo.module on line 49.
warning: array_merge() [function.array-merge]: Argument #2 is not an array in .../modules/contrib/tax_by_taxo/tax_by_taxo.module on line 49.
warning: Invalid argument supplied for foreach() in .../includes/form.inc on line 948.

begining on line 45:

<? php
    if (is_array($regions)) {
      foreach($regions as $regid => $region) {
        $reg[$region['region_realm'] .'_'. $regid] = $region['region_name'];
      }
      $locations = array_merge($locations, $reg);
?>

I solved it adding an array initialization:

<? php
    if (is_array($regions)) {
      foreach($regions as $regid => $region) {
        $reg[$region['region_realm'] .'_'. $regid] = $region['region_name'];
      }
      $locations = array_merge($locations, $reg);
      $locations = array_merge($locations, $reg);
?>

Comments

ferriol’s picture

Sorry, I'm not pasted the correct solved code:

<?php
  if (module_exists('ec_region')) {
    $regions = ec_region_get_regions('', 'ec_region');
    $reg = array();
    if (is_array($regions)) {
      foreach($regions as $regid => $region) {
        $reg[$region['region_realm'] .'_'. $regid] = $region['region_name'];
      }
      $locations = array();
      $locations = array_merge($locations, $reg);
?>
robertgarrigos’s picture

Status: Needs review » Fixed

I've applied to dev a simpler solution

if (module_exists('ec_region')) {
    $regions = ec_region_get_regions('', 'ec_region');
    if (is_array($regions)) {
      foreach($regions as $regid => $region) {
        $reg[$region['region_realm'] .'_'. $regid] = $region['region_name'];
      }
    }
  }
  $form['tax_by_taxo_settings']['tbt_region'] = array(
    '#type' => 'select',
    '#title' => t('Type of Location to define the new tax rule for'),
    '#default_value' => variable_get('tbt_region',''),
    '#options' => $reg,
    '#description' => t('Region of countries'),
  );
Anonymous’s picture

Status: Fixed » Closed (fixed)