You are here

function block_class_styles_form_alter in Block Class Styles 7

Same name and namespace in other branches
  1. 7.2 block_class_styles.module \block_class_styles_form_alter()

Implements hook_form_alter().

Related topics

File

./block_class_styles.module, line 159
Base module file for block_class_styles

Code

function block_class_styles_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'block_admin_configure' || $form_id == 'block_add_block_form') {
    $form['block_class']['#title'] = variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE);
    $form['block_class']['#description'] = variable_get('block_class_styles_fs_description', BLOCK_CLASS_STYLES_FS_DESCRIPTION);
    $block = new stdClass();
    $block->module = $form['module']['#value'];
    $block->delta = $form['delta']['#value'];
    $css_class = block_class($block);
    $multiple = FALSE;

    //@todo See admin.inc for explanation

    //$multiple = current(variable_get('block_class_styles_allow_multiple', BLOCK_CLASS_STYLES_ALLOW_MULTIPLE));
    $options = block_class_styles_info();
    $default = array(
      $css_class,
    );
    if (!$multiple) {
      $options = array(
        NULL => t('-None-'),
      ) + $options;
      $default = $css_class;
    }
    $form['block_class_styles'] = array(
      '#type' => 'fieldset',
      '#title' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
      '#description' => variable_get('block_class_styles_fs_description', BLOCK_CLASS_STYLES_FS_DESCRIPTION),
      '#collapsible' => TRUE,
      '#collapsed' => !variable_get('block_class_styles_form_collapsed', FALSE),
      '#weight' => variable_get('block_class_styles_form_weight', 0),
    );
    $form['block_class_styles']['css_class'] = array(
      '#type' => $multiple ? 'checkboxes' : 'select',
      '#title' => variable_get('block_class_styles_title', BLOCK_CLASS_STYLES_TITLE),
      '#options' => $options,
      '#default_value' => $default,
      '#description' => variable_get('block_class_styles_description', BLOCK_CLASS_STYLES_DESCRIPTION),
      '#maxlength' => 255,
    );

    // Can't set #access to FALSE because our variable name is the same, so we
    // have to anhialate this array member.
    unset($form['settings']['css_class']);
  }
}