Hi,

I added og_max_groups_poll to my feature, and exported my feature to code.

However, when I enabled this feature, the "group limit" field for "poll" on the "admin/node-type/poll" page becomes empty.

Any ideas?

Thanks

Hang

CommentFileSizeAuthor
#6 og-max_groups-settings-942270-6.patch596 bytesosopolar

Comments

soulfroys’s picture

soulfroys’s picture

This is my (Drupal newbie) fix for now...

function [my_module]_form_node_type_form_alter(&$form, &$form_state) {
  // Check if the Identity was loaded
  $identity = isset($form['identity']['type']['#default_value']);
  // Who has implemented the content type?
  $features_module = $form['#node_type']->module == 'features';
  // Get the type's machine name
  $type = isset($form['#node_type']->type);
  
  if (!$identity && $features_module && $type) {
    $og_max_groups_type = 'og_max_groups_' . $form['#node_type']->type;
    // Load the og_max_groups_[content_type] object
    $var = ctools_export_load_object('variable', 'names', array($og_max_groups_type));
    // Check if the Object was loaded
    if (count($var) > 0) {
      // Set the default Group Limit value
      $form['og']['og_max_groups']['#default_value'] = $var[$og_max_groups_type]->value;
    }
  }
}

[EDITED]
This worked for me as well and has less code:

function [my_module]_form_node_type_form_alter(&$form, &$form_state) {
  // Check if is a locked content type (by other modules like features, I think...)
  if ($form['#node_type']->locked == 1) {
    // If is locked, the correct is "$form['identity']['type']['#value']", and not "$form['identity']['type']['#default_value']"
    // Ref.: drupal.org/node/1127322
    $max_number = variable_get('og_max_groups_' . $form['identity']['type']['#value'],'');
    $form['og']['og_max_groups']['#default_value'] = $max_number;
  }
greggles’s picture

Thanks for your bug report and for helping make this a better module. Could you provide this as a patch?

hefox’s picture

Er, This is an organic group bug, right? It's currently in the features issue queue.

greggles’s picture

Project: Features » Organic Groups
Version: 6.x-1.0 » 6.x-2.x-dev
Component: Miscellaneous » og.module

great point ;)

osopolar’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new596 bytes

Patch for this. Just check if $form['identity']['type']['#value'] is set, if not fallback to $form['identity']['type']['#default_value'].

jastraat’s picture

+1 to the patch in #6

claudiu.cristea’s picture

Status: Needs review » Closed (outdated)

This version of Drupal is not supported anymore. If this is still an issue in the 8.x-1.x branch, please open a new up-to-date ticket. Closing.