1

I am using the Craft Contact Form plugin (https://github.com/craftcms/contact-form) and am having an issue where I get an error page on submission. The form is submitting correctly (the submission is appearing in Form Submissions from this plugin https://github.com/Rias500/craft-contact-form-extensions) but I am getting an error page.

Ideally I would like to be redirected to the same /contact page with the Success flash message displayed instead of the contact form

This is what I have on my contact.twig page template:

        <div class="contact-form">
          {% if craft.app.session.hasFlash('notice') %}
          <div class="notification">
    <p class="message notice">{{ craft.app.session.getFlash('notice') }}</p>
    </div>
{% elseif craft.app.session.hasFlash('error') %}
    <p class="message error">{{ craft.app.session.getFlash('error') }}</p>
{% else %}
<form method="post" action="" accept-charset="UTF-8">
    {{ csrfInput() }}
    <input type="hidden" name="action" value="contact-form/send">
    {{ redirectInput('contact') }}
      <div class="element">
      <label for="name">Name <span class="required">*</span></label>
      <input id="name" type="text" required name="fromName" value="{{ message.fromName ?? '' }}">
      </div>
      <div class="element">
      <label for="email">Email Address <span class="required">*</span></label>
      <input id="email" type="email" required name="fromEmail" value="{{ message.fromEmail ?? '' }}">
      </div>
      <div class="element">
      <label for="phone">Telephone Number</label>
      <input id="phone" type="text" required name="message[phone]" value="{{ message.phone ?? '' }}">
      </div>
      <div class="element">
        <p class="required-info text-small"><span class="required">*</span> Required Fields</p>
      </div>
      <div class="element">
        <label for="message">Message</label>
        <textarea rows="10" cols="40" id="message" name="message">{{ message.message ?? '' }}</textarea>
      </div>
    <input type="submit" value="Submit">
</form>
{% endif %}
</div>

And this is the error I get:

craft\web\twig\TemplateLoaderException: Unable to find the template “”. in /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/twig/TemplateLoader.php:122
Stack trace:
#0 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/twig/TemplateLoader.php(75): craft\web\twig\TemplateLoader->_resolveTemplate('')
#1 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/twig/twig/lib/Twig/Environment.php(270): craft\web\twig\TemplateLoader->getCacheKey('')
#2 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/twig/twig/lib/Twig/Environment.php(350): Twig_Environment->getTemplateClass('')
#3 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/twig/Environment.php(40): Twig_Environment->loadTemplate('', NULL)
#4 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/twig/twig/lib/Twig/Environment.php(289): craft\web\twig\Environment->loadTemplate('')
#5 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/View.php(337): Twig_Environment->render('', Array)
#6 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/rias/craft-contact-form-extensions/src/ContactFormExtensions.php(136): craft\web\View->renderTemplate('', Array)
#7 [internal function]: rias\contactformextensions\ContactFormExtensions->rias\contactformextensions\{closure}(Object(craft\contactform\events\SendEvent))
#8 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/yiisoft/yii2/base/Event.php(310): call_user_func(Object(Closure), Object(craft\contactform\events\SendEvent))
#9 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/yiisoft/yii2/base/Component.php(636): yii\base\Event::trigger('craft\\contactfo...', 'beforeSend', Object(craft\contactform\events\SendEvent))
#10 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/contact-form/src/Mailer.php(93): yii\base\Component->trigger('beforeSend', Object(craft\contactform\events\SendEvent))
#11 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/contact-form/src/controllers/SendController.php(59): craft\contactform\Mailer->send(Object(craft\contactform\models\Submission))
#12 [internal function]: craft\contactform\controllers\SendController->actionIndex()
#13 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('', Array)
#16 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('', Array)
#17 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('contact-form/se...', Array)
#18 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/Application.php(561): craft\web\Application->runAction('contact-form/se...', Array)
#19 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/craftcms/cms/src/web/Application.php(281): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#20 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/craft/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#21 /Users/user/Dropbox/GIANT/Potter Group Website/Site/build/public_html/index.php(21): yii\base\Application->run()
#22 {main}

I have no idea where I am going wrong with this so any help greatly appreciated.

Mike

1 Answer 1

2

If you want to redirect to the same page as you are sending, you can remove {{ redirectInput('contact') }} as per here.

Here though, it's the ContactFormExtensions plugin shouting at you. Do you have an email template set in there? If you enabled the 'Send confirmation' setting, you need to give it a template.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.