This behavior is designed to use as anti-spam solution e.g. for comments model. The basis of this solution is to use hidden fields in form and check if they are empty during validation. This is because most of spam-bots fill all fields in form. Real users doesn’t Second anti-spam solution is checking how long form is filled by submitter. Robots fills form really quick, while user need for that at least 1-2 seconds. Measuring time between creating model and saving it gives us answer if we are dealing with form filled by reals user of spam-bot.
Note, aim of this behavior is to avoid using captcha, as it isn’t user friendly solution and it is not so good as it should be in spam filtering. Off course you can use this extension together with captcha to strengthen your anti-spam mechanism.
If you have any interesting solution I can add to this extension do not hesitate to write here.
I know this is quite old, but I’m quite new to Yii and I was wondering if you could help me solve this.
I tried to implement this behavior on a basic (and recent, v1.1.14) Yii installation, and added it to the standard ContactForm as is (obviously changing the path) however it failed with the following error:
Event "ContactForm.onBeforeSave" is not defined.
The error goes away by adding replacing BeforeSave with onBeforeSave and then AfterSave with onAfterSave (as that was the next error coming up) in AiiAntiSpamBehavior, however I don’t think it’s doing anything.
Also, could you please clarify the intended usage of the field in emptyFieldsConfig? Is this supposed to be an existing field that’s going to be hidden by this extension or am I supposed to make up a field name that the behavior will then create dynamically? I tried it with an existing field, but after doing the above changes, my email field was still present (was not hidden).
Additionally submitTimeConfig also has a field, and the comment says “field where error message should be displayed”, so I’m guessing that would have to be a different field than the above, one that’s actually not hidden, am I correct?
Thanks in advance!