You are here

function entityform_block_block_view in Entityform block 7

Implements hook_block_view().

File

./entityform_block.module, line 28
Render any entity form into a block.

Code

function entityform_block_block_view($delta = '') {
  $types = variable_get('entityform_block_types');

  // Hide existing blocks if disabled
  if (entityform_block_exists($types, $delta)) {
    $entity_form = entityform_block_get_entity($delta);
    if ($entity_form && entityform_access('submit', $entity_form)) {
      $subject = $entity_form->label;
      $block = array();
      module_load_include('inc', 'entityform', 'entityform.admin');
      $block['subject'] = $subject;
      $form = entityform_form_wrapper(entityform_empty_load($delta), 'submit', 'embedded');
      $block['content'] = drupal_render($form);
      return $block;
    }
  }
}