Hi!
I tested this on my development site and also an two simplytest.me sites and my results were all the same.

Currently when the "Select or Other" "Radiobuttons/Checkboxes" widget is used no data is saved to the database and no error is returned. If you were previously using another widget for the Text(list) field and then start using the "Select or Other" "Radiobuttons/Checkboxes" widget, upon saving the data will be not saved and no items will be selected when you edit the content again. Checking the database shows that there are no records in the table.

Steps to reproduce:

  • Install Drupal 8 and enable the Select or Other module
  • Add a Text(List) field to an existing content type.

You can use one of the following lists for the allowed values to save time.

a|a
b7|ab
c2|abc
d3|abcd
e1|abcde
f9|abcdef
g4|abcdefg
h7|abcdefgh
i2|abcdefghi
j6|abcdefghij
k1|abcdefghijk
l3|abcdefghijkl
m7|abcdefghijklm
n5|abcdefghijklmn
o8|abcdefghijklmno
p2|abcdefghijklmnop
q6|abcdefghijklmnopq
r0|abcdefghijklmnopqr
s4|abcdefghijklmnopqrs
t1|abcdefghijklmnopqrst
u6|abcdefghijklmnopqrstu
v2|abcdefghijklmnopqrstuv
w9|abcdefghijklmnopqrstuvw
x3|abcdefghijklmnopqrstuvwx
y8|abcdefghijklmnopqrstuvwxy
z3|abcdefghijklmnopqrstuvwxyz
aa3|abcdefghijklmnopqrstuvwxyza
ab6|abcdefghijklmnopqrstuvwxyzab
ac2|abcdefghijklmnopqrstuvwxyzabc
ad9|abcdefghijklmnopqrstuvwxyzabcd
ä|ä
ö|ö
ü|ü
é|é
è|è
á|á
Ä|Ä
Ö|Ö
Ü|Ü
$|$
#|#
(|(
)|)
%|%
@|@
{|{
}|}
[|[
]|]
\|\
/|/
`|`
~|~
<|<
>|>
^|^
&|&
*|*
-|-
€|€

As you can see I was testing for length and special characters to see if they were the cause of the issue, but they were not.

  • Under the Manage form display tab select the widget type of Check boxes/Radio buttons
  • Create a piece of content and select some items on your Text(list) field. Save note that it does save them and they appear on the content when in view mode.
  • Repeat this with the Select List and the Select or other select list. Note that they too work and save.
  • Now repeat this with the Select or other Checkboxes/Radiobuttons. Note that when you save on the view page now nothing is shown from your Text(list) field, as nothing was saved.

Worst of all there is no error message displayed. Nothing is logged to the Drupal log. The user has no idea that they have just deleted their data. There is no error message to help the website administrator start to try and figure out what went wrong.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frederickjh created an issue. See original summary.

GuillaumeDuveau’s picture

Are you altering the field, like using #disabled or #access ? If yes, check this : https://www.drupal.org/project/select_or_other/issues/3011707

safetypin’s picture

I'm experiencing this issue as well. In a migrated content type where I've removed and added the correct field type to support this widget: "List (text)" the field values are migrated correctly, but when I edit and save the nodes, the data is removed from the database, and I'm unable to save any new values for this field in the database.

safetypin’s picture

And I'm not altering the field at all. I've also added the patch from #3011707 just to be sure.

safetypin’s picture

I'm pretty sure this is happening because the valueCallback function is reformatting the returned value array differently from the default checkboxes element.

frederickjh’s picture

@guix I do not believe am not altering the field in ways you describe, however I am not sure where one would do this.

As an interim solution I have switched to the default Drupal Check boxes/Radio buttons widget. This means the loss of the ability to sort and to allow the editor to add new items until this is fixed. I sorted the list in a spreadsheet that replaced it.

chriscalip’s picture

Bug sighted.
Patch attached.
@safetypin you are right, it was valueCallback method.

jason.bell’s picture

This bug was breaking our site. Patch in #7 allows the form to save and store values in the database again. However, to me it exposes a follow up issue that I need to look at more since the D8 behavior of this module appears drastically different than D7 without a very clear explanation on the project page.

When configuring a field type List (text) and providing allowed values, the expectation is that the form only provides those allowed values for selection. The Select or Other module then allowed users to check/radio an inserted “other” option and enter a new value.

The D8 version of this module is inserting user provided values into the allowed values list, thereby breaking the field configuration. Big bug in my eyes, so trying to do clean install with steps to reproduce.

jason.bell’s picture

legolasbo’s picture

Status: Active » Needs review
FileSize
4.16 KB

Turns out that this is also the issue causing #3071133: 'This value should not be null' when saving a multiple list field which I've written a failing regression test for. I've added that test to this patch.

Status: Needs review » Needs work

The last submitted patch, 10: 2875493-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

legolasbo’s picture

Status: Needs work » Fixed

Too bad that didn't also fix the other issue, but I've committed #7, because all tests passed on that one.

  • legolasbo committed 3d9a842 on 8.x-1.x
    Issue #2875493 by chriscalip, legolasbo: Data is removed from the...
gbirch’s picture

The patch in #7 works great when the user selects "other", but does not fix the bug when other is not selected. Patch attached.

Tests do not pass, but seemingly for other reasons.

gbirch’s picture

Priority: Normal » Critical

Honestly, I think that a bug that causes data loss during the normal, intended use of the module probably qualifies as critical, no?

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

This resolved the problem for me. Thank you @gbirch!

  • legolasbo committed 9ab1951 on 8.x-1.x authored by gbirch
    Issue #2875493 by gbirch, legolasbo, dawehner: Data is removed from the...
legolasbo’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x-1.x thanks!

PhilippVerpoort’s picture

Applying patches #7 and #14 has resolved the issue for me.

In case anybody comes across this and is trying to get this to work, please make sure you apply both patches!

Since I agree that this is issue is critical, I think it'd be good to release a new version of this module soon.

Thanks to everyone for their contributions.

Status: Fixed » Closed (fixed)

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

frederickjh’s picture

I have to agree with @PhilippVerpoort that it would be good to have even a new Alpha release with this code. This has been committed for over a year now without a release.