You are here

function webform_block_configure in Webform 7.4

Same name and namespace in other branches
  1. 6.3 webform.module \webform_block_configure()
  2. 7.3 webform.module \webform_block_configure()

Implements hook_block_configure().

File

./webform.module, line 2402
This module provides a simple way to create forms and questionnaires.

Code

function webform_block_configure($delta = '') {
  $nid = str_replace('client-block-', '', $delta);
  $node = node_load($nid);

  // Load the block-specific configuration settings.
  $webform_blocks = webform_variable_get('webform_blocks');
  $settings = isset($webform_blocks[$delta]) ? $webform_blocks[$delta] : array();
  $settings += array(
    'display' => 'form',
    'pages_block' => 1,
    'confirmation_block' => 0,
  );

  // Build a list of view modes for this node.
  $entity_info = entity_get_info('node');
  $view_modes = array(
    'form' => t('Form only'),
  );
  foreach ($entity_info['view modes'] as $view_mode_key => $view_mode_info) {
    $view_modes[$view_mode_key] = $view_mode_info['label'];
  }
  $form = array();
  $form['display'] = array(
    '#type' => 'select',
    '#title' => t('View mode'),
    '#default_value' => $settings['display'],
    '#options' => $view_modes,
    '#description' => t('The view mode determines how much of the webform to show within the block. You may <a href="!view_modes">customize different view modes</a> (other than the "Form only" mode) or even create new custom view modes if either the <a href="http://drupal.org/project/entity_view_mode">Entity view modes</a> or <a href="http://drupal.org/project/ds">Display Suite</a> modules are installed.', array(
      '!view_modes' => url('admin/structure/types/manage/' . $node->type . '/display'),
    )),
  );
  $form['pages_block'] = array(
    '#type' => 'radios',
    '#title' => t('Multi-page handling'),
    '#options' => array(
      1 => t('Display all pages inside block'),
      0 => t('Redirect to the node page after the first page'),
    ),
    '#default_value' => $settings['pages_block'],
    '#description' => t('If your webform has multiple pages, you may change the behavior of the "Next" button. This will also affect where validation messages show up after an error.'),
  );
  $form['confirmation_block'] = array(
    '#type' => 'radios',
    '#title' => t('Confirmation message'),
    '#options' => array(
      0 => t('Display as configured in the webform'),
      1 => t('Display the confirmation page in the block on the same page (no redirect)'),
    ),
    '#default_value' => $settings['confirmation_block'],
    '#description' => t("This setting overrides the webform's configuration and redirection location settings when the webform is submitted via this block."),
  );
  return $form;
}