You are here

function context_layouts_reaction_block::options_form in Context 7.3

Same name and namespace in other branches
  1. 6.3 context_layouts/plugins/context_layouts_reaction_block.inc \context_layouts_reaction_block::options_form()
  2. 6 context_layouts/plugins/context_layouts_reaction_block.inc \context_layouts_reaction_block::options_form()

Override of options form.

Overrides context_reaction_block::options_form

File

context_layouts/plugins/context_layouts_reaction_block.inc, line 119

Class

context_layouts_reaction_block

Code

function options_form($context) {
  $form = parent::options_form($context);
  $options = $this
    ->fetch_from_context($context);

  // Only alter the options form if the theme provides layouts.
  $theme_key = variable_get('theme_default', 'garland');
  $layouts = $this
    ->get_layout_options();
  if (!empty($layouts)) {
    $form['layout'] = array(
      '#title' => t('Layout'),
      '#description' => t('Choose one of the layouts provided by the default theme.'),
      '#options' => $layouts,
      '#type' => 'select',
      '#weight' => -100,
      '#default_value' => !empty($options['layout']) ? $options['layout'] : NULL,
      '#attributes' => array(
        'class' => array(
          'context-blockform-layout',
        ),
      ),
      '#required' => FALSE,
      '#empty_value' => 0,
      '#empty_option' => '- ' . t('Site default') . ' -',
    );

    // Add js.
    // @TODO: Move this to a theme function or somewhere that will get called even
    // if the form is using a cached version of itself (e.g. when validate fails).
    drupal_add_js(drupal_get_path('module', 'context_layouts') . '/plugins/context_layouts_reaction_block.js');
    drupal_add_js(array(
      'contextLayouts' => array(
        'layouts' => $this
          ->get_layout_regions(),
      ),
    ), 'setting');
  }
  return $form;
}