Hi

This module works great, but I found an issue.

I added a required field to the user registration page (user/register). I added the field since some bots were still getting past the spamicide check. I added a field that bots would have a hard time filling out properly, but humans would know what to do with.

If I fill in the username and email address fields but leave empty my extra required field, then when the page refreshes, it tells me my new required field is empty, highlights that field in red, but ALSO SHOWS THE SPAMICIDE field and its description (which by default says "leave this field empty"). How do I keep the spamicide field from showing if there is an error on the page related to other fields?

Thanks
-- hanksterr7

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GeduR’s picture

Status: Active » Needs review
FileSize
755 bytes

drupal_add_css doesn't work on validation error pages - for example submitting the form without required fields filled.

Because of this the module does not attach the css on non compressed css configurations. Instead we should use the form #attached function and not the drupal_add_ functions wich is called on form rebuild.

See #attached: https://api.drupal.org/api/drupal/developer%21topics%21forms_api_referen...

Attaching a patch, please review.

hanksterr7’s picture

Thanks!
I applied your patch (a one line line change replacing
drupal_add_css('public://' . variable_get('spamicide_dir', 'spamicide') . '/' . $spamicide_field . '.css');
with
$form['#attached']['css'][] = 'public://' . variable_get('spamicide_dir', 'spamicide') . '/' . $spamicide_field . '.css';
in function spamicide_form_alter() )

My initial attempt to create a new account (after applying the patch) while leaving my extra required field blank caused the spamicide field to show after submit. But when I cleared all caches again and tried again, the spamicide field no longer shows.

Will keep an eye on things to see that spamicide is still blocking registraitons, but so far so good!

GeduR’s picture

After applying the patch is needed to clear the caches because of the form cache. One trick is going to the form with a random query param: /user/login?rand=100 forcing rebuild the form.

So, hanksterr7 is this fixed?

hanksterr7’s picture

Yes, (per my limited talents -- I'm not a drupal php writer, by I know my way around code). Spamicide continues to block spam attempts nicely, and the spamicide field on the new user page no longer shows when a user fails to enter a required field. Thanks! Ok by me to commit the patch.

GeduR’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Could any of the maintainers check this?

candelas’s picture

patch works perfect in last dev.
GeduR thanks. i hope the maintainers have a spire moment and add it to the dev :)

candelas’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
lipcpro’s picture

Assigned: Unassigned » lipcpro
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.