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.. :/ :/ :/

and i call it in my .module file as :

$severity_levels = variable_get('kkkk_severity_levels', array());

Comments

rakesh.gectcr’s picture

I think you want to count the number of the error.

It is coming as an array so please try to use the PHP count function

For fetching the array use foreach function in PHP

---
Kind regards,

Thank you,
Rakesh James

Jverg’s picture

what i am really want is checkboxes with severity levels that e.g if the user selects error or warning or notice e.t.c it will go to db and take all errors or all the warnings or all the notices messages... That's what i am really want..