Allow using "OG-context" for non-group audience fields

This fix is not appropriate, when the URL contains two parameters of Entityreference, e.g. og_group_ref=xxx&other_entityreference_param_not_og_audience=xxx, is not work.

Sorry my bad english.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

> Sorry my bad english.

Your English is just fine :)

Nofar from Gizra will check it.

broon’s picture

I can confirm this issue. I have OG setup, each group has folders (node bundle) containing a entityreference field to OG audience (og_group_ref). This works fine.
"Within the folder", users can create files (another node bundle), it also has OG audience field (og_group_ref) and an additional entityreference field pointing to the folder it belongs to (field_folder).

Creating a new file is done by a link, e.g. /node/add/file?og_group_ref=12&field_folder=37&destination=node/12. The OG field is prepopulated just fine, however the field_folder throws an error ("Field Folder must be populated via URL.").

It used to work before last update, I just rolled back to 1.3 and it works again. So, version 1.4 is introducing this bug.

sayes1’s picture

I confirm too. I have downgrade to 7.x-1.3. and it works again.

ranroz’s picture

Status: Active » Needs review
FileSize
3.23 KB

The attached patch will provide additional control when repopulating fields. If the user chooses to use the OG context option, a source priority will be available in the field settings. This will allow to get a value from the URL even if OG context is used.

zihong0, Paul Broon - Could you try it out and see if that solves your issue?

zihong0’s picture

Yes, this patch has solved my problem. Thank you!

amitaibu’s picture

Title: #2160075 by Amitaibu: Allow using "OG-context" for non-group audience fields. » Allow using "OG-context" for non-group audience fields.
Status: Needs review » Needs work
  1. +++ b/plugins/behavior/EntityReferencePrepopulateInstanceBehavior.class.php
    @@ -73,6 +73,22 @@ class EntityReferencePrepopulateInstanceBehavior extends EntityReference_Behavio
    +      '#title' => 'Value source priority',
    

    Missing t().

  2. +++ b/plugins/behavior/EntityReferencePrepopulateInstanceBehavior.class.php
    @@ -73,6 +73,22 @@ class EntityReferencePrepopulateInstanceBehavior extends EntityReference_Behavio
    +        'og_context' => t('Prepopulate entity reference using the OG-context.'),
    +        'url' => t('Prepopulate entity reference from URL first if available.'),
    

    Make description more clear about what follows what.

    Maybe Use OG-context before/ after URL

ranroz’s picture

Status: Needs work » Needs review
FileSize
3.2 KB

@amitaibu-

Added t() function and changed description.

amitaibu’s picture

I have taken a different approach, where ER-prepopualte now has "providers" that you can enable and set the order from the UI.

Status: Needs review » Needs work

The last submitted patch, 8: 2162811-er-prepopulate-providers-8.patch, failed testing.

amitaibu’s picture

Version: 7.x-1.4 » 7.x-1.x-dev

Setting correct version for test bot.

amitaibu’s picture

Status: Needs work » Needs review

... and correct version.

amitaibu’s picture

Status: Needs review » Needs work

The last submitted patch, 8: 2162811-er-prepopulate-providers-8.patch, failed testing.

amitaibu’s picture

Status: Needs work » Needs review
FileSize
9.42 KB
583 bytes

Patch fixes test.

amitaibu’s picture

Patch adds better backwards computability, and adds tests.

amitaibu’s picture

Title: Allow using "OG-context" for non-group audience fields. » Add "Providers" functionality, and allow settings weight on them

Better title.

amitaibu’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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