You are here

function blockgroup_form_block_admin_display_form_alter in Block Group 7

Same name and namespace in other branches
  1. 7.2 blockgroup.module \blockgroup_form_block_admin_display_form_alter()

Implements hook_FORM_ID_alter().

Add delete-link to the main block administration form for blockgroups.

File

./blockgroup.module, line 422
Add block groups to block configuration page

Code

function blockgroup_form_block_admin_display_form_alter(&$form, &$form_state) {
  $blockgroups = blockgroup_list();
  foreach ($blockgroups as $delta => $title) {
    $region_key = blockgroup_get_region($delta);
    $region_anchor = 'region-' . $region_key;
    $block_key = 'blockgroup_' . $delta;
    $block_anchor = 'block-' . $region_key;

    // This is not a bug, I want to use region_key here (because of block_key uses an underscore).
    // Add go-to-block link
    $rtb_options = array(
      'fragment' => $block_anchor,
      'attributes' => array(
        'name' => $region_anchor,
      ),
    );
    $rtb_link = l(t('Go to block'), $_GET['q'], $rtb_options);
    $form['block_regions']['#value'][$region_key] .= ' ' . $rtb_link;

    // Add go-to-region link
    $btr_options = array(
      'fragment' => $region_anchor,
      'attributes' => array(
        'name' => $block_anchor,
      ),
    );
    $btr_link = l(t('Go to region'), $_GET['q'], $btr_options);
    $form['blocks'][$block_key]['info']['#markup'] .= ' ' . $btr_link;

    // Add delete link to block
    $form['blocks'][$block_key]['delete'] = array(
      '#type' => 'link',
      '#title' => t('delete'),
      '#href' => 'admin/structure/block/manage/blockgroup/' . $delta . '/delete',
    );
  }
}