I have a view with a field with multiple images, and i limit the output to just 1 image, the first one. Everything worked fine until i translated drupal with the locale module of the core to spanish. It started to print all images and it threw this error:
Notice: Undefined index: es en views_handler_field_field->get_items() (línea 562 de /var/www/drupal_prueba/drupal7_prueba/sites/all/modules/views/modules/field/views_handler_field_field.inc).

I resolved changing the line 562 and 587:
562 $all_values = $entity->{$this->definition['field_name']}[$langcode];
587 $entity->{$this->definition['field_name']}[$langcode] = $new_values;
I changed $langcode, with 'und', and it worked. But of course, surely this isn't the way to do it.

Comments

dagmar’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

I saw this issue a few days ago. This patch fix the problem.

However, field_language function is not called anymore. I don't know the implicacances of this.

bojanz’s picture

Status: Needs review » Needs work

It breaks translatable fields. Which is worse then a notice ;)

pcambra’s picture

Getting this same error, suscribe

metalinspired’s picture

Same here. However, I noticed that if I change the active language and error is gone. Still trying to figure out why.

Edit: Got rid of error by putting Content translation: Language (= Current user's language) into filters

dagomar’s picture

+1 Subscribing

roam2345’s picture

Following this one

roam2345’s picture

following this one

kdebaas’s picture

I have a similar issue. A view of nodes with multiple imagefields (displaying only the first one), looks all right in english. In spanish, it prints all the images from untranslated nodes. I am using entity translation, with language fallback, and the image fields are translateable. The errormessage reads: Notice: Undefined index: es en views_handler_field_field->set_items() (línea 676 de /home/kdb/web/example/modules/views/modules/field/views_handler_field_field.inc).

EndEd’s picture

In my case i get this error...

Notice: Undefined index: en in views_handler_field_field->set_items() (line 676 of C:\damp\www\es_gshop\sites\all\modules\views\modules\field\views_handler_field_field.inc).

...when i use in a view an image field with multiples images in it and tried to display the first one. Also no matter how i configure the Multiple field settings of the image field, I always see all images so i can not really only select the first one to see.

aristeides’s picture

subscribing

FallinHigh’s picture

subscribing

mrsimonelliott’s picture

I don't have the solution to this but I made an observation.

If node language is set to the same as default site language then views showing a single image from a multi-images field work as expected. If you change the site default lang or the node lang, the view outputs the error mentioned above and displays all images from the multi-field regardless of the view config.

We have only discussed multi image fields, I'm pretty sure this behaviour would be apparent whatever type of multi-field you are using.

This screen shot shows a view of two nodes of the same type, both with multiple images attached, the first node's language does not match site default lang, the second node's language does.
https://skitch.com/mrsimonelliott/r9fti/kledij-bashop

xandeadx’s picture

subscribing

how to reproduce error - http://drupal.org/node/1137408#comment-4389128

zambrey’s picture

subscribing

dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new826 bytes

What about this?

yatil’s picture

subscribe

jamsilver’s picture

StatusFileSize
new793 bytes
new1.14 KB

Confirmed that the patch in #15 solves my problem. Re-rolling the patch since the call to $this->field_language does nothing with this approach.

It looks unlikely that this is the right solution however since it looks like $this->field_language looks in some query settings and performs some substitutions?

bojanz’s picture

Yes, that's still a wrong solution.

anruether’s picture

subscribe

skilip’s picture

subscribe. Patch in #17 did remove the error. I cannot confirm this it the right solution either though.

Jerome F’s picture

Notice: Undefined index: en in views_handler_field_field->set_items() (line 676 of (...)/sites/all/modules/views/modules/field/views_handler_field_field.inc).
I confirm the image field with multiple values is not handled by views as configured. This view used to work before the activation of multilingual internationalisation modules.

Jerome F’s picture

This is breaking all my views, it's a really problematic issue.

Changed status according to @bojanz comment #18 and because the patch in #17 doesn't apply to last dev anymore.

And I submitted an issue in internationalisation views as well, as this is an issue only in a multilingual website: http://drupal.org/node/1169556

sonojacker’s picture

Status: Needs review » Needs work

I agree. I have been skimming through the "translation" module code, where we may get the more liable solution, as far as their function is not providing the value Views is instructed to use. Pls comment.

controla’s picture

subscribing

controla’s picture

subscribing

Jerome F’s picture

I reference to #18, @bojanz in your opinion what needs to be done to solve this problem correctly?

Jerome F’s picture

StatusFileSize
new9.49 KB

I use some views with multiple image fields, displaying only the first one and/or displaying each value on a single row. In english it worked ok, but once the translation modules are enabled, this bug breaks the views handling of multiple values fields.
In views, in the field edit form in Multiple field settings, when "Display all values in the same row" is unchecked, nothing is displayed in the view.
"Display 1 value(s)" doesn't work either, it displays the images as if "Display all values in the same row" was used.

Please find attached a view export for a simple multiple image field.

EDIT for clarification

Toktik’s picture

same problem. subscribing

Toktik’s picture

#17 patch works for me.

mac_weber’s picture

subs

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.17 KB

To sum up

* It should be possible to configure which language is used in the views interface: current/default/none
* It should be taken care that always an value is returned. field_language takes care of this

The problems on all this is the following:

* If no field translation is enabled, but locale module installed you still have 'und' for the field storage.

So here is a patch. This patch has to be tested and reviewed by as many people as possible!

kdebaas’s picture

StatusFileSize
new1.18 KB

Thanks! I applied the patch, and my views now work as expected.

I re-uploaded the patch, with some minor corrections of the English used in the comments.

re: * If no field translation is enabled, but locale module installed you still have 'und' for the field storage.: I believe another case scenario is when you are using language fallback, such as provided by the entity translation module (when language fallback is enabled, if a translation is not available for the requested language an existing one will be displayed). In that case the field is not stored as "und", but still causes the problems your patch solves.

derhasi’s picture

@dereine, I altered your patch (as discussed in IRC), so field_language() is now called in $this->field_language().

Field language is a main function of core's Field Language API, so we won't get around using it.

The patch in #31 and this one differ from #17, as they consider the language of the view, by passing it to field_language().

As dereine mentioned, this patch has to be tested and reviewed by as many people as possible! So, dear subscribers, please help to bring it in ;)

derhasi’s picture

StatusFileSize
new1.99 KB

... arg ... forgot the patch file... there it is:

kdebaas’s picture

Works for me.

+ // field_language takes sure that if the $langcode key doesn't exist LANGUAGE_NONE is used.
minor spelling mistake: takes->makes

pcambra’s picture

Applied patch in #34, the notices go away for me :)

zambrey’s picture

StatusFileSize
new1.99 KB

Works as advertised, thanks.
Fixed spelling mistake mentioned by kdebaas

dawehner’s picture

Assigned: Unassigned » bojanz

For me this looks now fine, but bojanz should really have a look at so assign to him

Jerome F’s picture

subscribe - I will definitely test this.

bojanz’s picture

Assigned: bojanz » Unassigned

The fix is correct. Great community work, everyone!

The comment was a bit fuzzy to me, although it gives a good example.
Maybe something like this would be better:

// Give the Field Language API a chance to fallback to a different language
// (or LANGUAGE_NONE), in case the field has no data for the selected language.
// field_view_field() does this as well, but since the returned language code
// is used before calling it, the fallback needs to happen explicitly.

Leaving the final judgement to dereine.

cpelham’s picture

Works for me, too.

dawehner’s picture

Status: Needs review » Fixed

Great. Commited to 7.x-3.x

Jerome F’s picture

http://drupal.org/node/1167292 marked as duplicate.

Thank you, last git today fixes the issue!

Pocketpain’s picture

Hey, I get an error while trying to patch with Drush.

Am I doing anything wrong when I:

1. Download patch.
2. Go to cd ..drupal/sites/all/modules/views/modules/field in Terminal
3. Type: patch < 1070744-field_language-37.patch

It says it failed on HUNK #1 at 644 and I get alot of more errors when I reload views.

Thanks!

dawehner’s picture

No this is not drush, that's normal bash.

patch -p1 < FILENAME is what you want.

In general you don't have to patch views, use the dev version.

Status: Fixed » Closed (fixed)

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

eigentor’s picture

Status: Closed (fixed) » Active

Had the same issue, fixed with 7.x-3.0-rc1 of views now.
An Issue that still appears to persist, though, is: if one does not check "display all results in the same row" in the multiple field settings, nothing gets displayed.

Or is there another issue for this?

dawehner’s picture

Do you know some more informations? Are this field actually empty on this particular node?
Sure there are always at least two issues :)

eigentor’s picture

No, the fields are not empty.
I tried another time and get a different result now :P

When I uncheck the "display all results in the same row", it displays all images of the first node, but none of the other nodes. I tell the view to use a pager and show 15 results on each page.

Here is the View I am referring to http://adventure-manufactory.com/de/tajik/tajik-image-galleries
The Galleries are single nodes with multiple Image fields and 10-20 images per field.

Cannot get my head round how this should look like, but shouldn't all images of all nodes be there with a pager?

dawehner’s picture

@eigentor
Which version did you used on this site?
In general i would recommend to run dev and test the patch from http://drupal.org/node/1303398

eigentor’s picture

O.K.
For me personally this is not so important at the moment.
So I'll keep track if I have the problem later again.

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Well it sorts of lacks information how to reproduce it. http://drupal.org/node/571990 is in general i fine description about this whole topic.

eigentor’s picture

Personally I can't say much more than I have nodes with imagefields with multiple images (set to unlimited), and a view that displays the images together with a title.
The view shall display only the first image of each field, which it does if I select "display all results in the same row" but doesn't if I do not select that.
The problem only appears if the locale module is enabled.

But you probably need more specific info...

tim.plunkett’s picture

Status: Postponed (maintainer needs more info) » Fixed

Setting back to fixed as it was in #42.
If this is still an problem, please open a new issue with clear steps to reproduce.

Status: Fixed » Closed (fixed)

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