It's very common developers want to have a default bundle in some situations.

Comments

manuelBS’s picture

+1

Toxid’s picture

I've been strugling with this for a while and would very much like to see it in this module. I find the menu part especially confusing.

nobarte’s picture

Example of default bundle can be found in Profile2 module in profile2.install file:

function profile2_install() {
  // Add an initial profile type, but only if installed manually. In case the
  // module is installed via an installation profile, skip that.
  if (!drupal_installation_attempted()) {
    $type = entity_create('profile2_type', array(
      'type' => 'main',
      'label' => t('Main profile'),
      'weight' => 0,
      'data' => array('registration' => TRUE, 'use_page' => TRUE),
    ));
    $type->save();
    user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('edit own main profile', 'view own main profile'));
    drupal_set_message(t('A main profile type has been created and assigned to all users. Go to the <a href="!url">Profile types</a> page to add some fields or to configure further profile types.', array('!url' => url('admin/structure/profiles'))));
  }
}

In the case of Model module:

  $type = entity_create('model_type', array(
     'type' => 'model_bundle',
     'label' => t('Model bundle'),
     'weight' => 0,
    ));
    $type->save();
kenorb’s picture

Category: Feature request » Support request
Issue summary: View changes
Status: Active » Closed (works as designed)

You can create bundle by going to admin/structure/model_types. I think the main point is to create custom bundles from the CMS, similar to entity types. I don't think having some default bundle have any outcome.

For some code examples, check: How do I programmatically create an entity with its fields?

kenorb’s picture

Category: Support request » Feature request