Thanks very much for the amazing module that og is.
I appreciate how complex the audience fieldset visibility is.
This is not a new problem and is still present in og-6.x-2.x-dev.
In case where audience is required and user is member of more than one group.
When creating new content the Groups audience fieldset is collapsed.
If user does not see this and saves the post they are warned that Audience is required and the fieldset is shown not collapsed. So it is handled gracefully.
When post is subsequently edited the audience fieldset is shown not collapsed.
It would be good if the audience fieldset is also not collapsed when new content is being created to save the user going through the warning if they don't see to select an audience.
Looking at the code in og.module around line 1920 shows:
if (module_exists('content')) {
$form['og_nodeapi']['#type'] = 'fieldset';
$form['og_nodeapi']['#title'] = t('Groups');
$form['og_nodeapi']['#group'] = 'additional_settings';
$form['og_nodeapi']['#collapsible'] = TRUE;
$form['og_nodeapi']['#collapsed'] = empty($groups);
$form['og_nodeapi']['#weight'] = content_extra_field_weight($form['#node']->type, 'og_nodeapi');
There is a lot of complex logic that precedes this but I it looks like the line with empty($groups)
suggests that if no group has yet been selected the fieldset will be collapsed. I am wondering where it would be best to add "OR audience is required" to display the fieldset for new content.
Thanks.
Comment | File | Size | Author |
---|---|---|---|
#2 | 1281762-2-og_do_not_collapse_required_audience_on_create_new_content.patch | 571 bytes | izmeez |
#1 | 1281762-og_do_not_collapse_required_audience_on_create_new_content.patch | 553 bytes | izmeez |
Comments
Comment #1
izmeez CreditAttribution: izmeez commentedRealized the solution may be quite simple. I have added a patch for review and changed the title for clarity.
Comment #2
izmeez CreditAttribution: izmeez commentedHere is a better patch that also preserves the original behaviour when audience is not required; create new content will collapse audience fieldset but on editing content will not collapse if an audience has been selected.
Comment #3
izmeez CreditAttribution: izmeez commentedJust a note. I deliberately did not use
$required
because even though admin users may not be required to declare an audience it is helpful for them to see the audience options if those are generally required of users.Comment #4
izmeez CreditAttribution: izmeez commented+bump
I wonder if someone might review this simple patch to see if it merits commit.
It is a simple issue that came from users and relates to the UX. Makes life a little easier for users :-)
Thanks,
Izzy
Comment #5
izmeez CreditAttribution: izmeez commented+bump
I'm still wondering if someone might review this. It is a simple patch that makes for consistency and better user experience. Currently, if a user is editing a post the audience is not collapsed but if they are creating a new post the audience is collapsed and more easily missed by the user. This patch makes the audience expanded on creating new post the same as it is on editing an existing post.
Comment #6
bessone CreditAttribution: bessone commented+1
Comment #7
Grayside CreditAttribution: Grayside commentedhttp://drupalcode.org/project/og.git/commit/9f707c9
I like it. I had some very minor reservations, but as I looked at the surrounding function and found some of the most convoluted code I've seen in months, there was nothing that could clean it up without a generalized refactor.
Comment #9
sano CreditAttribution: sano commentedIs this supposed to be available in the 6.x-2.4+13-dev build? I do have that build installed, but the groups fieldset block is still shown collapsed when creating new content.
Thank you
Sano
Comment #10
sano CreditAttribution: sano commentedWell, it looks like choosing Required in the Audience required field on the Organic groups configuration page makes the block expanded when creating content.