function module_weights_form_alter in Util 6.3
Same name and namespace in other branches
- 6.2 module_weights.module \module_weights_form_alter()
Implements hook_form_alter().
File
- ./
module_weights.module, line 99 - Allows module weights to be viewed and edited.
Code
function module_weights_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
// The admin modules page.
case 'system_modules':
if (!empty($form['description']['system_module'])) {
$weights = fetch_module_weights();
$form['weights'] = array(
'#tree' => TRUE,
);
foreach ($weights as $name => $weight) {
// We add "w_" to the name so as not to upset system module.
// kjh: don't set module weight for modules that aren't going
// to be rendered like hidden modules
if (isset($form['description'][$name])) {
$form['description'][$name]['weights']["w_{$name}"] = array(
'#type' => 'textfield',
'#default_value' => empty($weight) ? 0 : $weight,
'#title' => t('Module weight'),
'#size' => 4,
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
}
}
// Do my #submit before system.module's so all the rebuilding
// operations in system_module_submit use the new weights.
array_unshift($form['#submit'], 'module_weights_system_module_submit');
$form['#validate'][] = 'module_weights_system_module_validate';
}
break;
}
}