function alerts_form_alter
Search API
6.x alerts.module | alerts_form_alter(&$form, $form_id) |
File
- modules/
alerts/ alerts.module, line 748 - module file for Alerts
Code
function alerts_form_alter(&$form, $form_id) {
if ($form_id == 'content_edit_content_form') {
if (@$form ['type']['value'] == 'alert') {
fp_add_css(fp_get_module_path('alerts') . '/css/style.css');
$db = get_global_database_handler();
// If this is a NEW form, then check for values in the URL to auto-fill.
if ($form ['cid']['value'] === 'new') {
if (isset($_GET ['student_id'])) {
$form ['student_id']['value'] = $_GET ['student_id'];
$form ['student_id']['attributes'] = array('class' => 'hidden');
$extra_mark = "";
if ($form ['student_id']['value'] != "") {
$form ['mark_to'] = array(
'type' => 'markup',
'value' => "<div class='alert-field-mark alert-student'>
" . $db->get_student_name($form ['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
</div>",
'weight' => $form ['student_id']['weight'],
);
}
} // if _GET[student_id]
} // if "new"
else {
// This is NOT new! We display display the student information and hide the field.
$form ['student_id']['attributes'] = array('class' => 'hidden');
$extra_mark = "";
if ($form ['student_id']['value'] != "") {
$form ['mark_to'] = array(
'type' => 'markup',
'value' => "<div class='alert-field-mark alert-student'>
" . $db->get_student_name($form ['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
</div>",
'weight' => $form ['student_id']['weight'],
);
}
}
} // if type == alert
} // if form_id
}