You are here

function menu_attributes_form_menu_configure_alter in Menu Attributes 7

Same name and namespace in other branches
  1. 6.2 menu_attributes.module \menu_attributes_form_menu_configure_alter()
  2. 6 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 294
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) {
  if (!user_access('administer menu attributes')) {
    return;
  }
  $form['attributes_title'] = array(
    '#type' => 'item',
    '#title' => t('Menu item attribute options'),
  );
  $form['attributes_vertical_tabs'] = array(
    '#type' => 'vertical_tabs',
    '#attached' => array(
      'js' => array(
        drupal_get_path('module', 'menu_attributes') . '/menu_attributes.js',
      ),
    ),
  );
  $attributes = menu_attributes_get_menu_attribute_info();
  foreach ($attributes as $attribute => $info) {
    $form['attributes'][$attribute] = array(
      '#type' => 'fieldset',
      '#title' => $info['label'],
      '#group' => 'attributes_vertical_tabs',
      '#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' => '',
      '#states' => array(
        'invisible' => array(
          'input[name="menu_attributes_' . $attribute . '_enable"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    ) + $info['form'];
  }
}