We need to filter group audience fields on Add people page to offer only the ones which bundles are selected as target bundles in field settings.
If there is a user entity with two or more group audience fields and a user needs to be added from one of those groups as member, both audience fields are displayed and you can end up with an ugly error if you select the wrong one.
Real life scenario is:
You have a user with two group references (group audiences) for example Company and Business Account. If you go to Company Group page, click on Add people you have both group audiences there and you are able to select Business Account's here which is wrong and will result with the error above.
Comment | File | Size | Author |
---|---|---|---|
#1 | 2017709-filter-group-audience-fields-wheng-adding-people-to-group-1.patch | 1.05 KB | alesr |
Screenshot_2.png | 32.07 KB | alesr |
Comments
Comment #1
alesr CreditAttribution: alesr commentedPatch is attached.
Comment #3
alesr CreditAttribution: alesr commentedThere's this line in og_ui.admin.inc:
$field_name = !empty($form_state['values']['field_name']) ? $form_state['values']['field_name'] : key($field_names);
It's used few lines below here:
It doesn't make sense to use $field_name (which is a default field to display as #default_value in form select) in og_membership_create function. Like it's assuming you can only have one field as group_audience.
Comment #4
amitaibu> in og_membership_create function. Like it's assuming you can only have one field as group_audience.
When you create an OG-membership it's associated with a single field, so we need to pass it that field name.
Comment #5
alesr CreditAttribution: alesr commentedYes, but we can have more than one group_audience fields and we can't just take one and use it as default ($field_name).
This is also failing the test in #1.
Anyway we should switch the conversation to the original issue and $field_name will get in our way too.