You are here

function boxes_form_alter in Boxes 7

Implements hook_form_alter().

File

./boxes.module, line 497
Core functionality for boxes module.

Code

function boxes_form_alter(&$form, &$form_state, $form_id) {
  $path = implode('/', array_slice(arg(), 0, 5));
  if (($form_id != 'block_admin_configure' || $path != 'admin/structure/block/manage/boxes') && ($form_id != 'boxes_add_form' || arg(3) != 'box-add')) {
    return;
  }

  // Use the Box form submit handler.
  array_unshift($form['#submit'], 'boxes_box_form_submit');

  // Properly redirect to the correct admin page when a ?destination parameter
  // is not already provided (Eg, by contextual links).
  if (!empty($form['#action']) && strpos($form['#action'], '?destination=') == FALSE) {
    $form['#action'] .= '?destination=admin/structure/block';
  }

  // Cancel behavior is different here
  unset($form['cancel']['#attributes']);
  $form['cancel']['#submit'] = array(
    'boxes_block_cancel_submit',
  );
}