Form renders but does not submit
Closed this issue · 8 comments
I installed the module and it renders the form. When I submit a form, it redirects back to the home page, but never receive an email of the submission.
I can't find the simplecontactform-log.txt file, or any other signs that the form was successfully submitted.
Did I miss something? Any help is appreciated.
Check the action tag of the form. Did you specify it as an option? It should point to the same page.
Could you please provide some more information, e.g. ProcessWire Version, Module Version, PHP Version, did you pass options?
If you use the latest version, there's no redirect to the homepage anymore if the spam protection takes place.
I did not specify the action tag, but it is using the default value of action="./"
. All the default values are the same, I'm using first name, last name, email and message fields for the form.
ProcessWire 3.0.42
Module Version 1.0.1
PHP Version 5.6
Where should I be looking for the log file?
Backend / Admin > Setup > Logs > simplecontactform-log
So the log is not being generated, which I think means that SCF is not getting called when the form is submitted.
Should I change my action to something else? My form is located at www.example.com/contact but it redirects to www.example.com when submitted.
Also, I am using the plates templating system, maybe that is affecting it? Below are the PW classes I'm using in plates.
'site' => $site,
'modules' => $modules,
'pages' => wire('pages'),
'page' => wire('page'),
'config' => wire('config'),
'input' => wire('input'),
'sanitizer' => wire('sanitizer'),
'session' => wire('session'),
'roles' => wire('roles'),
'user' => wire('user'),
'users' => wire('users'),
'fields' => wire('fields'),
'templates' => wire('templates'),
'log' => wire('log')
Does SCF use anything that is not listed above?
I don't know the plates template system. But I also think that the module isn't called when the form is submitted.
How would you recommend I check if the form data is being submitted?
I've been testing different methods within the SCF module, but none of them are being triggered when the form is submitted (such as the Mailer function).
I would debug the module code to figure out if it's being called and at which point it stops.
As a first try, I would test if the render()
function is being executed (after line :299)
var_dump('test');
exit;
If this works, I would to the same with the renderForm
function (line :179) and so on.
One thing is a bit weird, the module never ever redirects to the homepage. So I guess, there is something before executing the module which redirects to the homepage. Do you use JavaScript? Could this interference with the module at some point?
Thanks for the help! Solved!
It turns out that the action="./"
was redirecting it back to the homepage. I simply had to change it to a relative URL for the active page. I know you mentioned this earlier, but I misread the relative url.
<?php
$scf = $modules->get('SimpleContactForm');
$options = array(
'action' => './' . $page->name . '/'
);
echo $scf->render($options);
?>
Thanks again!