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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shushu’s picture

Status: Active » Closed (cannot reproduce)

I 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 ?

jlscott’s picture

Status: Closed (cannot reproduce) » Active
FileSize
34.01 KB

I 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.

dobe’s picture

I 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.

dobe’s picture

I 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

amitaibu’s picture

Status: Active » Needs review

Correct status.
Any chance you can add a simpleTest?

dobe’s picture

I can give it a shot when I got a moment. I have never done this before.

-Jesse

amitaibu’s picture

> I have never done this before.

Cool. Don't worry, we are here to guide you :)

Beanjammin’s picture

Status: Needs review » Reviewed & tested by the community

The patch from #4 corrected the FieldValidationException for me on OG 7.x-2.7. Thanks!

dobe’s picture

I 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.

dobe’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.34 KB
2 KB

Ok here it is. Let me know.

-Jesse

The last submitted patch, 10: entityreference_fields_do_not_validate-2249261-10-test.patch, failed testing.

dobe’s picture

Status: Needs review » Reviewed & tested by the community

Switching it back, thought it had to be on needs review to run the test of the patch.

shushu’s picture

Status: Reviewed & tested by the community » Needs work

Since tests don't pass, there is still work to do.

dobe’s picture

Status: Needs work » Reviewed & tested by the community

Umm... 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

shushu’s picture

Status: Reviewed & tested by the community » Needs work

I 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.

dobe’s picture

Status: Needs work » Reviewed & tested by the community

I followed core documentation, #10 is still a valid and tested patch.

alcroito’s picture

Confirming, this fixed the issue for me, when using the latest version of OG shipped with Commons 7.x-3.13.

RobLoach’s picture

Confirmed. https://www.drupal.org/node/2249261#comment-8865219
entityreference_fields_do_not_validate-2249261-10.patch

jaesperanza’s picture

Confirmed #10 patch works. Thanks!

bsherwood’s picture

I 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.

Shiraz Dindar’s picture

#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.

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Sorry for waiting so long until the commit. Anyway, merged! :)

  • amitaibu committed dc6b78f on 7.x-2.x authored by dobe
    Issue #2249261 by dobe: FieldValidationException: error when saving...
Shiraz Dindar’s picture

Thank you!

Status: Fixed » Closed (fixed)

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