I am trying to make a sort of hook_setup_beans() function (similar to hook_setup_blocks()) to create some bean instances by default when a user turns on a bean_example module I am making. This would be called from hook_install().

Is there a standard path for doing this?

I am playing with bean_create() and bean_save() right now.

Thanks

p.s. I also posted this to http://drupal.stackexchange.com/questions/99918/how-do-i-programatically...

Comments

mohit_aghera’s picture

Is this you are looking for ?
https://drupal.org/node/1436186

  $bean = bean_create(array('type' => 'my_bean_type'));
  $bean->label = 'Administrative Label';
  $bean->title = 'Bean Title';
  $bean->delta = 'bean-machine-name';
  $bean->field_block_content = array(
    'en' => array(array(
      'value' => '<p>Text</p>',
      'format' => 'wysiwyg_editor',
    )),
  );
  $bean->save();
indytechcook’s picture

Status: Active » Fixed

Marking this as fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.