backdrop-contrib / paragraphs

Paragraphs module to control your content flow
https://backdropcms.org/project/paragraphs
GNU General Public License v2.0
5 stars 11 forks source link

Translation issues with modal admin #129

Closed laryn closed 2 years ago

laryn commented 2 years ago

I added locale/translation on a site and when a page has a language set, the modal admin won't save new paragraphs from the front end. Log shows:

Notice: Undefined index: en in ParagraphsItemEntity->save() (line 456 of /app/modules/paragraphs/ParagraphsItemEntity.inc).

Modal sorting is also affecting when languages are involved:

TypeError: Argument 1 passed to backdrop_sort() must be of the type array, null given, called in /app/modules/paragraphs/paragraphs.admin.inc on line 544 in backdrop_sort() (line 7272 of /home/managed/websites/jointheherd.net/production/web/core/includes/common.inc).

argiepiano commented 2 years ago

Looking at it very quickly....

That chunk of code is iterating through the hosting entity's field's delta to assign them a the paragraph entity, as in $node->field_name['en'][$delta]['entity'] = paragraph_entity

So I think the problem is with the host entity. It looks like the field in that host entity (the node) doesn't have a language code. Not sure why.

laryn commented 2 years ago

Thanks for checking, @argiepiano -- it does look like fields are not being saved with language codes (at least on a number of my sites, I haven't spun up a blank site to test yet). That does seem strange!

laryn commented 2 years ago

I linked a PR that solves it for now: https://github.com/backdrop-contrib/paragraphs/pull/130/files

Maybe it won't be needed if we track down why Backdrop fields seem to be always set to LANGUAGE_NONE.

laryn commented 2 years ago

Updating the top as it also seems to affect the modal sorting...