Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I get the following error when using the latest dev version of og and saving a configuration of any entity reference field.
FieldValidationException: Field validation errors in OgBehaviorHandler->validate() (line 295 of /Users/Bao/Sites/grammypro/grammypro/docroot/profiles/commons/modules/contrib/og/plugins/entityreference/behavior/OgBehaviorHandler.class.php).
I tried this out on a fresh installation of commons. Has anyone else experienced this error when configuring an entity reference field?
Comments
Comment #1
shushu CreditAttribution: shushu commentedI tried reproducing it on OG 2.x-dev and didn't get any error message.
Considering you refer to entityreference, which entityreference version are you using ?
Comment #2
jlscott CreditAttribution: jlscott commentedI can get the reported behaviour from both a select field, and a file upload field on an OG node entity that is configured with both og_field_access and editablefields.
I have a user with only an OG role of "member", which is allowed to view all fields, but only edit two of them (og_field_access). Both of these fields are configured with editablefields widgets in the pane used to display them on node-view. The "edit" button for each of these fields is correctly shown on the display.
Clicking the "edit" button in either field produces the correct behavior (either a select list, or a file upload dialog). However, when a slection is made from the select list, or an uploaded file is "saved", then I get the attached dialog window. The change is not saved.
However, if OG Strict node access permissions is unchecked and the user has edit permissions on this content type, the node entity displays with the "edit" tab available to the user. This tab brings up a display containing edit widgets for the two fields that the user has permission to change (plus the node title). These fields can be used to successfully edit the entity and change either of these fields.
Note: I am using og-7.x-2.7.
Comment #3
dobe CreditAttribution: dobe commentedI experienced this same issue. It does not occur when using OG Reference field widget. But it does when using Basic "Select" field widget for the entity reference (main reason for this is that I just need a simple selection of an organic group). Then go and save the settings form.
I am using latest dev version of both OG and Entity Reference.
Comment #4
dobe CreditAttribution: dobe commentedI found a fix. Based on the entityreference_field_validate() function. We are not checking if the target_id is NULL so it causes this error to be thrown if no default value is specified. The attached patch should fix this issue.
-Jesse
Comment #5
amitaibuCorrect status.
Any chance you can add a simpleTest?
Comment #6
dobe CreditAttribution: dobe commentedI can give it a shot when I got a moment. I have never done this before.
-Jesse
Comment #7
amitaibu> I have never done this before.
Cool. Don't worry, we are here to guide you :)
Comment #8
Beanjammin CreditAttribution: Beanjammin commentedThe patch from #4 corrected the FieldValidationException for me on OG 7.x-2.7. Thanks!
Comment #9
dobe CreditAttribution: dobe commentedI am sorry, I have been unable to find the time to build this test case. I am not sure if I will be able to find the time before drupalcon.
Comment #10
dobe CreditAttribution: dobe commentedOk here it is. Let me know.
-Jesse
Comment #12
dobe CreditAttribution: dobe commentedSwitching it back, thought it had to be on needs review to run the test of the patch.
Comment #13
shushu CreditAttribution: shushu commentedSince tests don't pass, there is still work to do.
Comment #14
dobe CreditAttribution: dobe commentedUmm... The Test that "Failed" shows that without the patch the Current state of the module fails the test. The test that passes shows that with the patch from #4 the test passes... Please test the patch.
I followed the instructions on how to create a core test case and applied it to the module, If your un-familiar with this you can see how this is done at: https://drupal.org/contributor-tasks/write-tests
#11-#13 explain this in detail.
-Jesse
Comment #15
shushu CreditAttribution: shushu commentedI think you need to add the tests into the patch, leaving just one patch file. This way the tests and patch will be together when testing.
Comment #16
dobe CreditAttribution: dobe commentedI followed core documentation, #10 is still a valid and tested patch.
Comment #17
alcroito CreditAttribution: alcroito commentedConfirming, this fixed the issue for me, when using the latest version of OG shipped with Commons 7.x-3.13.
Comment #18
RobLoachConfirmed. https://www.drupal.org/node/2249261#comment-8865219
entityreference_fields_do_not_validate-2249261-10.patch
Comment #19
jaesperanza CreditAttribution: jaesperanza commentedConfirmed #10 patch works. Thanks!
Comment #20
bsherwood CreditAttribution: bsherwood commentedI am also receiving this error when I try and save the og_group_ref field on the manage fields tab.
This seems like major bug, since it stops the user from changing any field settings for OG. Can we get this rolled into the 7,2 branch? Patching may work, but many site admins only stick with stable releases (like me).
Thank you.
Comment #21
Shiraz Dindar#10 works for me as well. Tests are passing now as well. Commit it baby!
For those just joining, the patch in #10 resolves a validation error when saving field settings of an entity reference field which uses Organic Groups entity selection mode but does not use the OG Reference widget.
Comment #22
amitaibuSorry for waiting so long until the commit. Anyway, merged! :)
Comment #24
Shiraz DindarThank you!