mardi 24 février 2015

I want to connect my Form table with checkboxes

This is my code for the Severities Checkbox. It shows me a checkbox with the values of Emergency, Alert, Warning e.t.c and i want when someone check one of the values and press the submit button i want: e.g if i check the warning checkbox i want to see only the warning messages: Here is the code of the checkboxes:



$form['blablabla'][$key] = array(
'#type' => 'select',
'#options' => drupal_map_assoc(array('', t('Emergency'), t('Alert'), t('Critical'), t('Error'), t('Warning'), t('Notice'), t('Info'), t('Debug'))),
'#default_value' => variable_get($key),
);


And here follows the code with my table :



/**
* Table with Errors
*/
// Begin building the query.
$query = db_select('watchdog', 'th')
->extend('PagerDefault')
->orderBy('wid')
->fields('th')
->limit(80);

// Fetch the result set.
$result = $query->execute();

// Loop through each item and add to the $rows array.
foreach ($result as $row) {
$Severities = unserialize($row -> variables);
//if ($key == 'warning') {
if($Severities['%type'] == 'Warning') {
$rows[] = array(
$row -> wid,
$Severities['%type'],
$Severities['!message'] . ' in ' . $Severities['%function'] . ' (line ' . $Severities['%line'] . ' of ' . $Severities['%file'] . ' ).',
);
}
}
// }
$header = array('ID', 'Severity', 'Message');
$form['table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);




Aucun commentaire:

Enregistrer un commentaire