Skip to content
Snippets Groups Projects
Commit 92d11627 authored by Ian S. H. Ward's avatar Ian S. H. Ward
Browse files

By alex_b, Ian Ward better handle multiple values and empty values in field mapping

parent 525b8154
No related branches found
No related tags found
No related merge requests found
...@@ -54,12 +54,21 @@ function field_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_na ...@@ -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. * Ensure that $value is a numeric to avoid database errors.
*/ */
function field_feeds_set_target_numeric($source, $entity, $target, $value) { function field_feeds_set_target_numeric($source, $entity, $target, $value) {
if (is_numeric($value)) { if (!is_array($value)) {
field_feeds_set_target($source, $entity, $target, $value, FALSE); $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) { 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); field_feeds_set_target($source, $entity, $target, $value, TRUE);
} }
...@@ -71,6 +80,10 @@ function field_feeds_set_target_text($source, $entity, $target, $value) { ...@@ -71,6 +80,10 @@ function field_feeds_set_target_text($source, $entity, $target, $value) {
* element the user has picked as a source. * element the user has picked as a source.
*/ */
function field_feeds_set_target($source, $entity, $target, $value, $input_format = FALSE) { 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. // Handle non-multiple value fields.
if (!is_array($value)) { if (!is_array($value)) {
$value = array($value); $value = array($value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment