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.
It looks like there is an issue with the og_menu_node_form_validate function. This is checking the value in the 'group_audience' field which does not exist. I think this should check both the og_group_ref and the og_group_ref_other_groups (or whatever other group fields there may be).
Something like this? Line 604 of og_menu.module
if (isset($form_state['values']['og_group_ref'][LANGUAGE_NONE]) || isset($form_state['values']['og_group_ref_other_groups'][LANGUAGE_NONE])) {
if (isset($form_state['values']['og_group_ref'][LANGUAGE_NONE])) {
foreach ($form_state['values']['og_group_ref'][LANGUAGE_NONE] as $item => $gid) {
$gids[] = $gid['target_id'];
}
}
if (isset($form_state['values']['og_group_ref_other_groups'][LANGUAGE_NONE])) {
foreach ($form_state['values']['og_group_ref_other_groups'][LANGUAGE_NONE] as $item => $gid) {
$gids[] = $gid['target_id'];
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#5 | og_menu-validation-1702580-5.patch | 1 KB | osopolar |
#1 | og_menu-Validation_Error-1702580.patch | 1.42 KB | zipymonkey |
Comments
Comment #1
zipymonkey CreditAttribution: zipymonkey commentedFound a better fix for this that uses the og_get_group_audience_fields function. Patch is attached.
Comment #2
rv0 CreditAttribution: rv0 commentedyour patch had mixed line endings and didn't apply due to previous patches, so I had to manually edit
Comment #3
zipymonkey CreditAttribution: zipymonkey commentedThanks rv0. I think I need take a look at my eclipse settings...
Comment #4
jvieille CreditAttribution: jvieille commentedThis issue dates back D6 or earlier.
Actually, when the adience selection is disabled, no groups are available for checking, so it fails
(the $gids variable then contains one item 0=>0)
In D6, I have simply modiifed the function og_menu_node_form_validate. It test that the first GID is 0=> 0 (not an empty array actually)
Comment #5
osopolarIn case of max group limit = 1 together with issue #707114: Improve group post node form for a max-groups limit of 1. the
$form_state['values']['og_groups']
will be a string, not an array. This case will result in the same error.@jvieille: Can't see the case in which $gids[0] !== 0. How to you disable the audience selection? If you use
['#access'] = FALSE
for the field the og_groups will be there. You just disable the validation for your case. If there are no gids in the form_state I guess the node already exists, so you will get the gids by callingog_get_node_groups($node)
, won't you? I'd like to add this case to the patch, but I don't know how to test it (because I don't know how to disable the audience selection).Comment #6
rv0 CreditAttribution: rv0 commentedwhat is this patch for ? D6?
Comment #7
osopolarSorry for not mentioning, yes it's for D6 and only when patch in #707114: Improve group post node form for a max-groups limit of 1. is used. In the end I'm not sure if it's worth to use patch in #707114, because there are some more problems there.