You are here

function blocktheme_form_block_form_alter in Block Theme 8

Form for updating a block.

File

./blocktheme.module, line 75
Provides a configuration option to select custom themes for blocks

Code

function blocktheme_form_block_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
  $var_name = $form['id']['#default_value'];
  $options = blocktheme_get_blockthemes();
  $blocktheme = blocktheme_get();
  $blocktheme_vars = blocktheme_get_vars();
  $form['settings']['#weight'] = -2;
  $form['regions']['#weight'] = -1;
  $form['custom_block_theme'] = array(
    '#type' => 'details',
    '#title' => t('Block Theme'),
    '#weight' => 0,
    '#collapsed' => FALSE,
    '#open' => TRUE,
  );
  $form['custom_block_theme']['blocktheme'] = array(
    '#type' => 'select',
    '#title' => t('Custom theme'),
    '#default_value' => isset($blocktheme[$var_name]) ? $blocktheme[$var_name] : '',
    '#options' => $options,
  );
  $form['custom_block_theme']['blocktheme_vars'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom block variables'),
    '#description' => t('Enter one entry per line, in the format: <em>variable_name|variable_content</em>.'),
    '#wysiwyg' => FALSE,
    '#default_value' => isset($blocktheme_vars[$var_name]) ? blocktheme_format_vars_admin($blocktheme_vars[$var_name]) : '',
  );
  $form['actions']['submit']['#submit'][] = 'blocktheme_update';
}