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.


p.s. I also asked this at https://drupal.org/node/2173783


Creating bean instance programmatically. 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',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.