You are here

function menu_token_form_alter in Menu Token 5

Implementation of hook_form_alter().

File

./menu_token.module, line 6

Code

function menu_token_form_alter($form_id, &$form) {
  if ($form_id == 'menu_edit_item_form') {

    // Move 'Path' field  into a fieldset
    $path_field = $form['path'];
    $form['path'] = array(
      '#type' => 'fieldset',
      '#collapsible' => FALSE,
    );
    $form['path']['path'] = $path_field;
    $token_enabled = variable_get('menu_token_enabled', array());
    $form['path']['token_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use tokens in @path', array(
        '@path' => t('Path'),
      )),
      '#description' => theme('token_help', 'menu_token'),
      '#default_value' => isset($token_enabled[$form['mid']['#value']]),
    );

    // Replace submit handler taking care on sort
    $form_submit = array();
    foreach ($form['#submit'] as $function => $params) {
      $function = $function == 'menu_edit_item_form_submit' ? 'menu_token_edit_item_form_submit' : $function;
      $form_submit[$function] = $params;
      unset($function);
      unset($params);
    }
    $form['#submit'] =& $form_submit;
  }
  elseif ($form_id == 'menu_item_delete_form') {
    $form['#submit']['menu_token_item_delete_form_submit'] = array();
  }
}