You are here

function menu_attributes_form_menu_configure_alter in Menu Attributes 6.2

Same name and namespace in other branches
  1. 6 menu_attributes.module \menu_attributes_form_menu_configure_alter()
  2. 7 menu_attributes.module \menu_attributes_form_menu_configure_alter()

Implements hook_form_FORM_ID_alter().

Alters the menu settings form with our menu attribute settings.

See also

menu_configure_form()

File

./menu_attributes.module, line 251
Alters the menu item form to allow the administrator to specify additional attributes for the menu link

Code

function menu_attributes_form_menu_configure_alter(&$form, $form_state) {
  $form['attributes'] = array(
    '#type' => 'item',
    '#title' => t('Menu item attribute options'),
  );
  $attributes = menu_attributes_get_menu_attribute_info();
  foreach ($attributes as $attribute => $info) {
    $form['attributes'][$attribute] = array(
      '#type' => 'fieldset',
      '#title' => $info['label'],
      '#group' => TRUE,
      '#description' => $info['form']['#description'],
    );
    $form['attributes'][$attribute]["menu_attributes_{$attribute}_enable"] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable the @attribute attribute.', array(
        '@attribute' => drupal_strtolower($info['label']),
      )),
      '#default_value' => $info['enabled'],
    );
    $form['attributes'][$attribute]["menu_attributes_{$attribute}_default"] = array(
      '#title' => t('Default'),
      '#description' => '',
    ) + $info['form'];
  }

  // Ensure the buttons sink to the bottom of the form.
  $form['buttons'] += array(
    '#weight' => 100,
  );

  // Add vertical tabs to these fieldsets if it is available.
  if (module_exists('vertical_tabs')) {
    $form['attributes']['#pre_render'][] = 'vertical_tabs_form_pre_render';
  }
}