function monolog_profile_form in Monolog 6
Same name and namespace in other branches
- 7 monolog.admin.inc \monolog_profile_form()
Form for adding and editing logging profile configurations.
Parameters
stdClass $profile: The logging profile configuration.
1 string reference to 'monolog_profile_form'
- monolog_menu in ./
monolog.module - Implements hook_menu().
File
- ./
monolog.admin.inc, line 248 - Administrative settings for the Monolog module.
Code
function monolog_profile_form($form, &$form_state, $profile = null) {
$form['#is_new'] = null === $profile;
$base_path = 'admin/config/development/monolog/profile';
if ($form['#is_new']) {
$profile = monolog_profile_new();
}
$form['#monolog'] = array(
'profile' => $profile,
);
$form['handlers'] = array(
'#type' => 'value',
'#value' => $profile->options['handlers'],
);
$form['label'] = array(
'#title' => t('Label'),
'#type' => 'textfield',
'#default_value' => $profile->options['label'],
'#description' => t('The human-readable name of the logging profile.'),
'#required' => TRUE,
'#maxlength' => 255,
'#size' => 30,
);
$form['name'] = array(
'#type' => 'machine_name',
'#default_value' => $profile->name,
'#maxlength' => 32,
'#machine_name' => array(
'exists' => 'monolog_profile_load',
'source' => array(
'label',
),
),
'#disabled' => !$form['#is_new'],
'#description' => t('The machine readable name of the logging profile. This value can only contain letters, numbers, and underscores.'),
);
if (!$form['#is_new']) {
$link = l(t('Add handler'), $base_path . '/' . $profile->name . '/handler/add');
$form['action_link'] = array(
'#markup' => '<ul class="action-links"><li>' . $link . '</li></ul>',
);
$form['channel_table'] = array(
'#theme' => 'monolog_handler_table',
'#tree' => TRUE,
'#monolog' => array(
'profile' => $profile,
'handler_info' => monolog_handler_info_load_all(),
),
);
foreach ($profile->options['handlers'] as $name => $handler) {
$form['channel_table']['level'][$name] = array(
'#type' => 'select',
'#title' => t('Logging level for @handler', array(
'@handler' => $handler['label'],
)),
'#title_display' => 'invisible',
'#default_value' => $handler['level'],
'#options' => monolog_level_options(),
);
$form['channel_table']['bubble'][$name] = array(
'#type' => 'select',
'#title' => t('Bubble setting for @handler', array(
'@handler' => $handler['label'],
)),
'#title_display' => 'invisible',
'#default_value' => $handler['bubble'],
'#options' => array(
1 => t('Yes'),
0 => t('No'),
),
);
$form['channel_table']['weight'][$name] = array(
'#type' => 'select',
'#title' => t('Weight for @handler', array(
'@handler' => $handler['label'],
)),
'#title_display' => 'invisible',
'#options' => drupal_map_assoc(range(-10, 10)),
'#default_value' => $handler['weight'],
'#attributes' => array(
'class' => array(
'monolog-handler-weight',
),
),
);
}
}
$form['actions'] = array(
'#type' => '#actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save logging profile'),
);
$form['actions']['cancel'] = array(
'#markup' => l(t('Go back to logging profiles page'), $base_path),
);
$form['#submit'][] = 'monolog_profile_form_submit';
return $form;
}