/**
  * Override EntityReferenceHandler::settingsForm().
  */
 public static function settingsForm($field, $instance)
 {
     $form = parent::settingsForm($field, $instance);
     $entity_type = $field['settings']['target_type'];
     $entity_info = entity_get_info($entity_type);
     $bundles = array();
     foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
         if (og_is_group_type($entity_type, $bundle_name)) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
     }
     if (!$bundles) {
         $form['target_bundles'] = array('#type' => 'item', '#title' => t('Target bundles'), '#markup' => t('Error: The selected "Target type" %entity does not have bundles that are a group type', array('%entity' => $entity_info['label'])));
     } else {
         $settings = $field['settings']['handler_settings'];
         $settings += array('target_bundles' => array(), 'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT);
         $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $settings['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type acting as group, that can be referenced. Optional, leave empty for all bundles.'));
         $options = array();
         foreach (og_membership_type_load() as $og_membership) {
             $options[$og_membership->name] = $og_membership->description;
         }
         $form['membership_type'] = array('#type' => 'select', '#title' => t('OG membership type'), '#description' => t('Select the membership type that will be used for a subscribing user.'), '#options' => $options, '#default_value' => $settings['membership_type'], '#required' => TRUE);
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public static function settingsForm($field, $instance)
 {
     $referenced_fields = array();
     foreach (field_info_fields() as $f) {
         if (isset($f['bundles'][$instance['entity_type']]) && in_array($instance['bundle'], $f['bundles'][$instance['entity_type']]) && $f['type'] == 'entityreference') {
             $referenced_fields[$f['field_name']] = $f['field_name'];
         }
     }
     $form['project_field'] = array('#type' => 'select', '#title' => t('Field containing project reference'), '#options' => $referenced_fields, '#default_value' => isset($field['settings']['handler_settings']['project_field']) ? $field['settings']['handler_settings']['project_field'] : 'none');
     $form += parent::settingsForm($field, $instance);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public static function settingsForm($field, $instance)
 {
     $form = parent::settingsForm($field, $instance);
     $issue_node_types_options = array();
     $node_type_names = node_type_get_names();
     foreach ($node_type_names as $machine_name => $label) {
         if (project_issue_node_type_is_issue($machine_name)) {
             $issue_node_types[$machine_name] = $label;
         }
     }
     $form['target_bundles']['#options'] = $issue_node_types;
     return $form;
 }
 /**
  * Generate a settings form for this handler.
  */
 public static function settingsForm($field, $instance)
 {
     $project_behaviors = project_get_behavior_info();
     $project_behavior_options = array();
     foreach ($project_behaviors as $module => $behavior_info) {
         $machine_name = $behavior_info['machine name'];
         $project_behavior_options[$machine_name] = $behavior_info['label'];
     }
     $form['behavior'] = array('#type' => 'select', '#title' => t('Project behavior'), '#options' => $project_behavior_options, '#default_value' => !empty($field['settings']['handler_settings']['behavior']) ? $field['settings']['handler_settings']['behavior'] : 'none');
     $form += parent::settingsForm($field, $instance);
     // We're overriding the bundles.
     unset($form['target_bundles']);
     return $form;
 }
 /**
  * Override settings form().
  */
 public static function settingsForm($field, $instance)
 {
     $form = parent::settingsForm($field, $instance);
     $entity_type = $field['settings']['target_type'];
     $entity_info = entity_get_info($entity_type);
     $bundles = array();
     foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
         if (og_is_group_type($entity_type, $bundle_name)) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
     }
     if (!$bundles) {
         $form['target_bundles'] = array('#type' => 'item', '#title' => t('Target bundles'), '#markup' => t('Error: The selected "Target type" %entity does not have bundles that are a group type', array('%entity' => $entity_info['label'])));
     } else {
         $settings = $field['settings']['handler_settings'];
         $settings += array('target_bundles' => array(), 'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT, 'reference_type' => 'my_groups', 'primary_field' => FALSE, 'hide_secondary_field' => TRUE);
         $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $settings['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type acting as group, that can be referenced. Optional, leave empty for all bundles.'));
         $options = array();
         foreach (og_membership_type_load() as $og_membership) {
             $options[$og_membership->name] = $og_membership->description;
         }
         $form['membership_type'] = array('#type' => 'select', '#title' => t('OG membership type'), '#description' => t('Select the membership type that will be used for a subscribing user.'), '#options' => $options, '#default_value' => $settings['membership_type'], '#required' => TRUE);
         $form['reference_type'] = array('#type' => 'select', '#title' => t('Reference'), '#options' => array('my_groups' => t('My groups'), 'other_groups' => t('Other groups'), 'all_groups' => t('All groups')), '#description' => t('What groups should be referenced.'), '#default_value' => $settings['reference_type']);
         $options = array('0' => t('None'));
         // Get all the other group audience fields in this bundle.
         $entity_type = $instance['entity_type'];
         $bundle = $instance['bundle'];
         $fields_info = field_info_fields();
         foreach (field_info_instances($entity_type, $bundle) as $field_name => $field_instance) {
             if ($field_name == $field['field_name']) {
                 // This is the current field.
                 continue;
             }
             if ($fields_info[$field_name]['type'] != 'entityreference' || $fields_info[$field_name]['settings']['handler'] != 'og') {
                 // This is not an Entity reference field.
                 continue;
             }
             if (!empty($fields_info[$field_name]['settings']['handler_settings']['primary_field'])) {
                 // Field is already a secondary field.
                 continue;
             }
             $options[$field_name] = $field_instance['label'] . ' (' . $field_name . ')';
         }
         $form['primary_field'] = array('#type' => 'select', '#title' => t('Primary field'), '#description' => t('Select a field that will be populated with the values of this field.'), '#options' => $options, '#default_value' => $settings['primary_field'], '#required' => TRUE, '#element_validate' => array('og_handler_primary_field_validate'));
         $form['hide_secondary_field'] = array('#type' => 'checkbox', '#title' => t('Hide secondary field'), '#description' => t('Show the secondary field only to users with "administer group" permission.'), '#default_value' => $settings['hide_secondary_field'], '#states' => array('invisible' => array(':input[name="field[settings][handler_settings][primary_field]"]' => array('value' => 0))));
         form_load_include($form_state, 'php', 'og', '/plugins/selection/og.class');
     }
     return $form;
 }