0

I want a form with checkboxes that will have all the severity levels and when the user (e.g selects only the error i want to select only the errors from watchdog. My problem now is that in watchdog the severities are with numbers :/ :/ :/.....here is my form:

/**
 * Settings form for the user.
 */
function kkkk_admin_settings() {

    // Form for the severity checkboxes.
    $kkkk_severity_levels = variable_get('kkkk_severity_levels', array());

    // Declare empty options array.
    $kkkk_severity_options = array();

    // Loop through each severity level and push to options array for form.
    foreach (watchdog_severity_levels() as $number_select => $severity) {
      $kkkk_severity_options[$severity] = drupal_ucfirst(
        $severity);
    }
    $kkkk_form['kkkk_severity_levels'] = array(
      '#type'          => 'checkboxes',
      '#title'         => t('Type of log messages'),
      '#options'       => $kkkk_severity_options,
      '#default_value' => array_values($kkkk_severity_levels),
      '#required'      => TRUE,
    );
    dsm($kkkk_severity_levels);
    return system_settings_form($kkkk_form);
  }
}

this dsm($kkkk_severity_levels);if i have selected error gets me out:

error (String, 4 characters ) error
emergency (Integer) 0
alert (Integer) 0
critical (Integer) 0
warning (Integer) 0
notice (Integer) 0
info (Integer) 0
debug (Integer) 0

I need to take out :

    error (String, 4 characters ) 3
    emergency (Integer) 0
    alert (Integer) 0
    critical (Integer) 0
    warning (Integer) 0
    notice (Integer) 0
    info (Integer) 0
    debug (Integer) 0

where 3 is the number of the error severity. I need to take this number in order in my function to select only the error messages from watchdog.... Could someone help?? If I need a new form could you help with that form plz ?? I am new in coding.. :/ :/ :/

  • That '#default_value' looks wrong to me. You're assigning an array to it. Perhaps you want to set that statically, or do a string match in your options loop to assign the value for the default you want. Sorry, I see it's checkboxes, I thought it was a select. What do you get if you dsm($kkkk_severity_options)? – murraybiscuit May 12 '15 at 11:23
  • For future questions, I suggest making the title more descriptive - the current title gives little meaningful information to readers. – murraybiscuit May 12 '15 at 11:36
  • dsm($kkkk_severity_options) gets me out:emergency (String, 9 characters ) Emergency, alert (String, 5 characters ) Alert, critical (String, 8 characters ) Critical, error (String, 5 characters ) Error, warning (String, 7 characters ) Warning, notice (String, 6 characters ) Notice, info (String, 4 characters ) Info, debug (String, 5 characters ) Debug , – Karmen May 12 '15 at 11:50
  • and if i change the line with $kkkk_severity_options[$severity]=drupal_ucfirst($severity) and put $kkkk_severity_options[$number_select] = drupal_ucfirst($severity); – Karmen May 12 '15 at 11:53
  • dsm(kkk_severity-options) gets me out 0 (String, 9 characters ) Emergency, 1 (String, 5 characters ) Alert 2 (String, 8 characters ) Critical 3 (String, 5 characters ) Error, 4 (String, 7 characters ) Warning, 5 (String, 6 characters ) Notice, 6 (String, 4 characters ) Info, 7 (String, 5 characters ) Debug, – Karmen May 12 '15 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.