From 92d116277db6908f45ec38afd359ff3858aecd62 Mon Sep 17 00:00:00 2001 From: "Ian S. H. Ward" <ian_ward@4736.no-reply.drupal.org> Date: Thu, 28 Oct 2010 18:34:58 +0000 Subject: [PATCH] By alex_b, Ian Ward better handle multiple values and empty values in field mapping --- mappers/field.inc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mappers/field.inc b/mappers/field.inc index 3a10441f..e2910b16 100644 --- a/mappers/field.inc +++ b/mappers/field.inc @@ -54,12 +54,21 @@ function field_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_na * Ensure that $value is a numeric to avoid database errors. */ function field_feeds_set_target_numeric($source, $entity, $target, $value) { - if (is_numeric($value)) { - field_feeds_set_target($source, $entity, $target, $value, FALSE); + if (!is_array($value)) { + $value = array($value); + } + foreach ($value as $k => $v) { + if (!is_numeric($v)) { + unset($value[$k]); + } } + field_feeds_set_target($source, $entity, $target, $value, FALSE); } function field_feeds_set_target_text($source, $entity, $target, $value) { + if (!is_array($value)) { + $value = array($value); + } field_feeds_set_target($source, $entity, $target, $value, TRUE); } @@ -71,6 +80,10 @@ function field_feeds_set_target_text($source, $entity, $target, $value) { * element the user has picked as a source. */ function field_feeds_set_target($source, $entity, $target, $value, $input_format = FALSE) { + // @param $value must be an array, and not empty. + if (empty($value)) { + return; + } // Handle non-multiple value fields. if (!is_array($value)) { $value = array($value); -- GitLab