Multiple apps in the form tag and SPAM!

  • Last year I launched a site that included a fairly complicated estimate request form. The form allows end users to upload images of damage to their vehicle along with a load of other data. To handle the way images were managed I wrote a custom app to take the result of the form submission, process it and attach all the images into a nicely templated email. This works perfectly.


    To make use of Perch's built in validation I use two apps in the form tag.


    Code
    1. <perch:form id="estimate_form" app="perch_forms epicfox_mailer" role="form" method="post" class="has-dropzone">


    The form submission has, unsurprisingly, started attracting a lot of spam. It has a honeypot field and recently I installed reCatptcha v2 but spam was still getting through daily.


    I suggested we move on to try Akismet but during setup something occurred to me.


    Do multiple apps in the form tag get processed sequentially and does validation failure or a positive spam result from one prevent the processing of the next? I'm starting to think that this is not always the case and that the spam result from the system is being ignored when my app kicks in.


    Does anyone have a view or definitive answer to this?

    Is it possible to get the result of the previous apps validation and/or spam result so i can check it before sending my email?


    Thanks in advance.

  • drewm

    Approved the thread.
  • We've already discussed this on Slack, but for posterity's sake and because the forum is a lot easier to search here is my response:


    Do multiple apps in the form tag get processed sequentially and does validation failure or a positive spam result from one prevent the processing of the next?


    They get processed sequentially, but the result of either does not effect the other as far as I know.



    I think your app may better listen to the perch_forms.received event instead of handling the form submission directly. It is only fired when the submission is not spam. This would work assuming all the data you need is available in the received response (including the images).


    PHP
    1. $API = new PerchAPI(1.0, 'epicfox_mailer');
    2. $API->on('perch_forms.received', function(PerchSystemEvent $Event){
    3. // do something
    4. });