Posted by greta_drupal on April 19, 2011 at 4:35pm
Would like to display the join groups as select list (single select fine) rather than checkboxes. Ideas?
Google produced one other post requesting same (in OG issues), but no replies.
TY.
Would like to display the join groups as select list (single select fine) rather than checkboxes. Ideas?
Google produced one other post requesting same (in OG issues), but no replies.
TY.
Comments
$mymodule_form_alter($form_id
$mymodule_form_alter($form_id, &$form) {
if($form_id == '$og-form-id') {
$form['$og-join-select']['#type'] = 'select';
}
}
You'll need to find the values for $og-form-id and $og-join-select (drupal_set_message and Devel module are your friends here) but that should give you the general idea...
Orlando, FL Web Developer | http://www.garethsprice.com/
And, where do you recommend
And, where do you recommend that I employ this?
Create a custom module...
Create a custom module... create a folder in sites/all/modules called mymodule, create a mymodule.info file (use another module for a template), create a mymodule.module file that contains the code above (modified to actually work :) ), then Site Building, Modules and you'll be able to turn it on like any other Drupal module.
Orlando, FL Web Developer | http://www.garethsprice.com/
I suspected that you meant
I suspected that you meant custom form alter mod, but wanted to confirm. Thanks for suggestion.
(I hacked the og.module file to change type from "checkbox" to "select", for registration form, just to test. No change.)
I've seen the Organic Groups
I've seen the Organic Groups selection form do some funky stuff - depending on your permissions and stuff - might want to make sure you were in the right part of the function. Also, please try to flush your Drupal site cache and browser cache just to make sure.
if you do end up making a function mymodule_form_alter in a custom module, grab and enable the devel module and call dsm($form); inside your function to see what the object looks like at that point.
Ryan Price
DrupalEasy Podcast
Here is where I tried
Here is where I tried changing it (the only place I need select list):
// registration checkbox
// get the visibility for normal users
$visibility = variable_get('og_visibility_registration', OG_REGISTRATION_CHOOSE_FALSE);
// admin can always choose registration checkbox - get right default
if (user_access('administer nodes')) {
$visibility = in_array($visibility, array(OG_REGISTRATION_NEVER, OG_REGISTRATION_CHOOSE_FALSE)) ? OG_REGISTRATION_CHOOSE_FALSE : OG_REGISTRATION_CHOOSE_TRUE;
}
$default = FALSE;
switch ($visibility) {
case OG_REGISTRATION_NEVER:
$form['og_register'] = array('#type' => 'value', '#value' => 0);
break;
case OG_REGISTRATION_ALWAYS:
$form['og_register'] = array('#type' => 'value', '#value' => 1);
break;
case OG_REGISTRATION_CHOOSE_TRUE:
$default = TRUE;
// fall through
case OG_REGISTRATION_CHOOSE_FALSE:
$form['og_register'] = array(
'#type' => 'checkbox',
'#title' => t('Registration form'),
'#default_value' => isset($node->og_register) ? $node->og_register : $default,
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_register') : 0,
'#description' =>t('May users join this group during registration? If checked, a corresponding checkbox will be added to the registration form.'),
);
break;
}
I don't think that is the
I don't think that is the place. Looks like this is when you are setting up options - whether or not that group should appear in the registration form.
To paraphrase Star Wars: "This is not the form you're looking for."
Check out line #1975 (I'm assuming Drupal 6 and the latest OG)
<?phpif (count($options)) {
$form['og_register'] = array('#type' => 'fieldset', '#title' => t('Groups'));
$form['og_register']['og_register'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => $default_value,
);
return $form;
}
?>
Ryan Price
DrupalEasy Podcast
Ah, shoot. You are right.
Ah, shoot. You are right. That'll teach me to nap at the laptop.
So, how do I target that one
So, how do I target that one specifically? They both reference the same $form.
Also, I prefer the checkboxes on the full registration page; but need the select list only on the registration form block (via Form Block), on front page. Is that even possible?
I would bet that Form Block
I would bet that Form Block is changing the Form ID somehow - you should be able to *_form_alter just the block's form, I hope.
Ryan Price
DrupalEasy Podcast
Did flush all caches.
Did flush all caches.