We are starting to use paragraphs and find it to be exactly what we've long needed for design flexibility. We use multiselect module across the site to allow the user to select items in a particular order. We like the interface and flexibility. But these two modules are not playing nice together.

We have a paragraph field with a node reference field in that paragraph bundle. Let's call it field_paragraph with a field_reference inside of that bundle.

When we create a node with the paragraph item field_reference and select a few things, it saves fine. The next time we go in to edit, the selected list is empty. Saving results in an empty field.

On the edit, we have a few errors in the dblog for multiselect.module:

Notice: Undefined index: field_collection_item in _multiselect_after_build() line 176
Notice: Undefined index: in _multiselect_after_build() line 177
Warning: Invalid argument supplied for foreach() in _multiselect_after_build() line 177

We do use field_collection for other things, but not with this paragraph feature. I've tried to just take the field_collection "else if" statement out, but it returns just an empty select list with no errors. I've tried to make a second "else if" for my situation, but I'm not having any luck.

Any help would be greatly appreciated!
Heidi

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hwasem created an issue. See original summary.

chOdec’s picture

Hi, we experienced similar problems..

I tried to make a patch witch should solve:

- fix for multiselect in Paragraphs
- fix for combination of Paragraphs and Field Collection (entity with multiselect inside entity inside Node)
- fix ID of element in case of multiple field values (items are assigned to the right select, not to the first one)

I have no experience with contributing to community, so please, can anybody check this patch?

hwasem’s picture

I haven't had a chance to test this on my client project yet. I'm hoping to do so next week. I'm hopeful this will help as we have a few sites holding on this issue.

leo_li’s picture

Hi, I got similar problems.

Besides, if I add several paragraph bundles which contain multiselect field, all the multiselect fields couldn't work proprely except the one in the first paragraph.

hwasem’s picture

@leo_li, yes I saw this happening as well.

kevin.davis’s picture

@chodec, thanks for the patch! It resolved the errors was I receiving with multiselect inside an inline entity form.

I recreated the file using Git diff and a more standard naming scheme.

hwasem’s picture

Status: Active » Needs review
JeebsUK’s picture

I've just encountered this issue using Multiselect with Profile2 as well.

deepeshvishwa’s picture

Hi, I have used your patch and like it !

But if you want to use it with paragraphs then you must change one line of code in this patch:

Existing Code:
else if ((module_exists('field_collection') && $element['#entity_type'] == 'field_collection_item') || (module_exists('field_collection') && $element['#entity_type'] == 'paragraphs_item')) {

New Code:
else if ((module_exists('field_collection') && $element['#entity_type'] == 'field_collection_item') || (module_exists('paragraphs') && $element['#entity_type'] == 'paragraphs_item')) {

I have implemented and it's working fine :)

rgpublic’s picture

I've added a small fix for Drupal8 under issue #2996932 - just in case anybody is looking for this.