1

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 asked this at https://drupal.org/node/2173783

1

Creating bean instance programmatically. https://drupal.org/node/1436186

<?php
  $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();
?>

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.