We've installed OG Vocabulary and tried to follow the setup instructions to the letter. We have five groups, each with one vocabulary, and one content type that has an OG Vocab Entity Reference field. It all works beautifully unless we attach a file to the content type. Then, at save, we're told that the OG Vocabulary term is required - for every group. The field is not required, which makes it all the more odd. Without an attachment, there is no problem.

Any thoughts?

#2 og_context_file_upload_fix.diff1.86 KBsyastrov
Members fund testing for the Drupal project. Drupal Association Learn more


syastrov’s picture

When the upload button of a File field is clicked, in addition to uploading the file, the form is rebuilt underneath.
But when being rebuilt, it doesn't know which group the form belongs to, so it falls back on including vocabulary fields for all of the groups the user belongs to (which, in the case of the admin user is every single group), although you cannot see them until you submit the form and the page is reloaded.
When the form is finally is finally submitted, it tries to validate all of these vocabulary fields (not just the one for the current group), some of which may be required.

I have made a patch which adds an og_context handler for the 'file/ajax' path, which is called when a file is uploaded. This gets the group context from the $_SESSION. I think that there could be a way to pull this from the form itself or perhaps from the query string instead. This way, when the form is rebuilt, it only includes the correct vocabulary field for the group connected with the form.

syastrov’s picture

Issue summary: View changes
1.86 KB
syastrov’s picture

This issue is related to the way Organic Groups og_context module handles file upload.
See Make OG Context aware to parent form in file upload ajax calls.

syastrov’s picture