function spamicide_pre_render_place_spamicide in Spamicide 5
Same name and namespace in other branches
- 7 spamicide.module \spamicide_pre_render_place_spamicide()
Place the spamicide field just before the submit button
Parameters
$form_id:
$form:
1 string reference to 'spamicide_pre_render_place_spamicide'
- spamicide_form_alter in ./
spamicide.module - Implementation of hook_form_alter
File
- ./
spamicide.module, line 436 - This module provides yet another tool to eliminate spam.
Code
function spamicide_pre_render_place_spamicide($form_id, &$form) {
// search the weights of the buttons in the form
$button_weights = array();
foreach (element_children($form) as $key) {
if ($form[$key]['#type'] == 'submit' || $form[$key]['#type'] == 'button') {
$button_weights[] = $form[$key]['#weight'];
}
}
if ($button_weights) {
// set the weight of the Spamicide element a tiny bit smaller than the lightest button weight
// (note that the default resolution of #weight values is 1/1000 (see drupal/includes/form.inc))
$first_button_weight = min($button_weights);
$spamicide_field = _spamicide_get_field($form_id);
if ($spamicide_field) {
$form[$spamicide_field]['#weight'] = $first_button_weight - 0.5 / 1000.0;
}
else {
$form['spamicide']['#weight'] = $first_button_weight - 0.5 / 1000.0;
}
// make sure the form gets sorted before rendering
unset($form['#sorted']);
}
}