[[!FormIt? &hooks=`spam,ampGetUser` &submitVar=`amp_find_person_submit` ]] <form id="amp_find_person_form" action="[[~[[*id]]]]#FindPerson" method="post" class="c-form"> <input type="hidden" name="nospam:blank" value="" /> <div class="row"> <div class="small-12 columns"> <input type="email" name="amp_find_person_email_address" id="amp_find_person_email_address" /> </div> </div> <div class="row"> <div class="small-12 columns"> <button id="amp_find_person_submit" name="amp_find_person_submit" type="submit" value="Find Person">Find Person</button> </div> </div> </form> [[!$validate.ampFindPerson:jsToBottom]]
<script>
$("#amp_find_person_form").submit(function(event) {
$("#amp_find_person_submit").attr("disabled", true);
}); // Disable multiple submits
</script><?php $modx->log(modX::LOG_LEVEL_ERROR,'The form has been submitted.'); return true;
[2016-09-06 09:20:06] (ERROR @ /Users/patrickappelman/Sites/gr/core/cache/includes/elements/modsnippet/168.include.cache.php : 2) The form has been submitted. [2016-09-06 09:20:06] (ERROR @ /Users/patrickappelman/Sites/gr/core/cache/includes/elements/modsnippet/168.include.cache.php : 2) The form has been submitted. [2016-09-06 09:20:06] (ERROR @ /Users/patrickappelman/Sites/gr/core/cache/includes/elements/modsnippet/168.include.cache.php : 2) The form has been submitted. [2016-09-06 09:20:06] (ERROR @ /Users/patrickappelman/Sites/gr/core/cache/includes/elements/modsnippet/168.include.cache.php : 2) The form has been submitted. [2016-09-06 09:20:06] (ERROR @ /Users/patrickappelman/Sites/gr/core/cache/includes/elements/modsnippet/168.include.cache.php : 2) The form has been submitted.
This question has been answered by BobRay. See the first response.
You might try setting the submit variable to '' in your posthook.
<?php
$_POST['amp_find_person_submit'] = '';
$submitvar = $hook->getValue('amp_find_person_submit');
$modx->log(modX::LOG_LEVEL_ERROR,'The form has been submitted. Submit var is ' . $submitvar);
return true;Hi BobRay, even when setting the value of my submitvar to '' in my posthook, it still writes 5 lines to error.log.
Do you call the FormIt snippet in the content of the resource? Are there multiple [[*content]] tags in the template? Do you use a snippet that fills the description html tag or similar with the content field?
That could lead to multiple execution of the FormIt call and to multiple execution of the custom hook.