function menu_position_menu_position_rule_user_page_form in Menu Position 7
Adds form elements for the User plugin to the rule configuration form.
Parameters
$form: A reference to the "add/edit rule" form array. New form elements should be added directly to this array.
$form_state: A reference to the current form state.
File
- plugins/
menu_position.user_page.inc, line 51 - Provides the User rule plugin for the Menu Position module.
Code
function menu_position_menu_position_rule_user_page_form(&$form, &$form_state) {
// If this is an existing rule, load the variables stored in the rule for this plugin.
$variables = !empty($form_state['#menu-position-rule']['conditions']['user_page']) ? $form_state['#menu-position-rule']['conditions']['user_page'] : array();
// To ensure that the plugin's form elements are placed inside vertical tabs,
// all elements should be placed inside a collapsed fielset inside the
// $form['conditions'] array.
$form['conditions']['user_page'] = array(
'#type' => 'fieldset',
'#title' => t('User page'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attached' => array(
// Ensures a proper summary is added to its vertical tab.
'js' => array(
drupal_get_path('module', 'menu_position') . '/plugins/menu_position.user_page.js',
),
),
);
$form['conditions']['user_page']['user_page_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Apply this rule on user account pages.'),
'#default_value' => !empty($variables['user_page_enable']) ? $variables['user_page_enable'] : 0,
'#description' => t('Check to apply this rule to user pages, e.g. user/1 or users/admin'),
'#weight' => -20,
);
// Add a submit handler.
$form['#submit'][] = 'menu_position_menu_position_rule_user_page_form_submit';
}