I'm creating a custom module which adds a submit handler to a form. The idea is that it checks whether a hidden "honeytrap" field has been filled in.
If the field has been filled in, a success message is shown, but the form content is not e-mailed. If the field has not been filled in, the form is submitted as normal.
I don't want to use a form validator here (so this answer on DSE is unfortunately no use). I want the spam robot to think that the form has been submitted, so that it doesn't try again and learn about my special field.
At present, I have the following code:
function par_report_repair_form_webform_client_form_26_alter(&$form, &$form_state, $form_id)
{
array_unshift($form['#submit'], 'honeytrap_submit_handler');
}
function honeytrap_submit_handler($form, $form_state)
{
// what goes here?
}
I'm not clear what to put in my submit handler. I'd like the following behaviour:
- If the honeytrap field has been filled in, display a "success" message but don't allow any additional handlers to run
- If the honeytrap field hasn't been filled in, continue as normal.
Any suggestions? I've tried simply setting $form['#submit']
to be an empty array, but that didn't help.