This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

CricciDisk
CricciDisk

Hello! Thank you all for making such a wonderful CMS. :)

I'm currently working on a new website for our small shop, and so far, October has made this a wonderfully simple process! However, I've hit a small roadblock while creating a contact form. For reference, I've been learning OctoberCMS from the supplied documentation as well as Watch+Learn's OctoberCMS YouTube series.

This frontend contact form's intention is to: (a) Email a single email address with the submitted form, and (b) To log the submission on a Builder plugin on the backend for archiving purposes. For development purposes, I'm using XAMPP on localhost with a MySQL database and a basic Mailgun account for emailing.

After clicking "submit" on the frontend, I receive the following pop-up alert. Of note, this submits and saves to the builder plugin perfectly, but does not send out an email.

"Call to a member function getAttribute() on null" on line 489 of C:\xampp\htdocs\(site)\vendor\erusev\parsedown-extra\ParsedownExtra.php

I've checked for inconsistencies between the sample code from the Watch+Learn videos as well as the October documentation, but unfortunately, I'm stuck. The following is the code from a few select spots on the plugin--since this is my first time requesting some technical help, please let me know if there are any additional files needed for reference. :)

The HTML form component inside the plugin, which is placed on the "contact" page of the website, filepath "C:\xampp\htdocs(site)\plugins(vendor)\generalcontact\components\generalcontactform\default.htm":

<form data-request="generalcontactform::onSend" data-request-validate>
<div class="input-chunk">
    <label for="contactName">Your Name</label><br>
    <input id="contactName" type="text" name="contact_name">
    <span data-validate-for="contact_name">Please enter your name.</span>
</div>

<div class="input-chunk">
    <label for="contactCompany">Company or Organization Name</label><br>
    <input id="contactCompany" type="text" name="contact_company"><br>

    <input id="contactNewOrCurrent" type="checkbox" name="contact_neworcurrent" value="New Contact"> <label for="contactNewOrCurrent">(I'm New!)</label>
</div>

<div class="input-chunk">
    <label for="contactPhoneNumber">Phone Number</label><br>
    <input id="contactPhoneNumber" type="text" name="contact_phone">
    <span data-validate-for="contact_phone">Please enter a valid phone number and/or an email address.</span>
</div>

<div class="input-chunk">
    <label for="contactEmailAddress">Email Address</label><br>
    <input id="contactEmailAddress" type="email" name="contact_email">
    <span data-validate-for="contact_email">Please enter a valid phone number and/or an email address.</span>
</div>

<div class="input-chunk">
    <label for="contactBlurb">What's Up?</label><br>
    <textarea id="contactBlurb" name="contact_blurb"></textarea>
    <span data-validate-for="contact_blurb">Please enter some details regarding your request.</span>
</div>

<div class="input-chunk">
    <label>Preferred Contact Days</label><br>
    <input type="checkbox" id="anyDay" name="contact_preferreddays" value="Any Business Day" checked> <label for="anyDay">Any Business Day</label><br>
    <input type="checkbox" id="mondays" name="contact_preferreddays" value="Mondays"> <label for="mondays">Mondays</label><br>
    <input type="checkbox" id="tuesdays" name="contact_preferreddays" value="Tuesdays"> <label for="tuesdays">Tuesdays</label><br>
    <input type="checkbox" id="wednesdays" name="contact_preferreddays" value="Wednesdays"> <label for="wednesdays">Wednesdays</label><br>
    <input type="checkbox" id="thursdays" name="contact_preferreddays" value="Thursdays"> <label for="thursdays">Thursdays</label><br>
    <input type="checkbox" id="fridays" name="contact_preferreddays" value="Fridays"> <label for="fridays">Fridays</label>
</div>

<div class="input-chunk">
    <label>Preferred Contact Times</label><br>
    <input type="checkbox" id="anyTime" name="contact_preferredtimes" value="Any Time" checked> <label for="anyTime">Any Business Time</label><br>
    <input type="checkbox" id="morning" name="contact_preferredtimes" value="Morning"> <label for="morning">Morning</label><br>
    <input type="checkbox" id="earlyafternoon" name="contact_preferredtimes" value="Early Afternoon"> <label for="earlyafternoon">Early Afternoon</label><br>
    <input type="checkbox" id="lateafternoon" name="contact_preferredtimes" value="Late Afternoon"> <label for="lateafternoon">Late Afternoon</label>
</div>

<button type="submit">Submit Form</button>

</form>

The Plugin.php file, filepath "C:\xampp\htdocs(site)\plugins(vendor)\generalcontact\Plugin.php":

    <?php namespace (Vendor)\GeneralContact;

use System\Classes\PluginBase;

class Plugin extends PluginBase
{
    public function registerComponents()
    {
        return [
            '(Vendor)\GeneralContact\Components\GeneralContactForm' => 'generalcontactform',
        ];
    }

    public function registerSettings()
    {
    }
}

The "generalcontactform.php" component, filepath "C:\xampp\htdocs(site)\plugins(vendor)\generalcontact\components\generalcontactform.php"

    <?php namespace (Vendor)\GeneralContact\Components;

use Cms\Classes\ComponentBase;
use (Vendor)\GeneralContact\Models\GeneralMessage;
use Input;
use Mail;
use Validator;
use ValidationException;
use Redirect;

class GeneralContactForm extends ComponentBase
{
    public function componentDetails() {
        return [
            'name' => 'General Contact Form',
            'description' => 'Company Contact Form'
        ];
    }

    public function onSend() {

        $data = post();

        $rules = [
                'contact_name' => 'required',
                'contact_company' => 'nullable',
                'contact_neworcurrent' => 'nullable',
                'contact_phone' => 'required_without:contact_email',
                'contact_email' => 'required_without:contact_phone|email',
                'contact_blurb' => 'required',
                'contact_preferreddays' => 'nullable',
                'contact_preferredtimes' => 'nullable'
        ];

        $validator = Validator::make($data, $rules);

        if($validator->fails()) {
            throw new ValidationException($validator);

        } else {
            // Save to Backend
            $generalmessage = new GeneralMessage();
            $generalmessage->contact_name = Input::get('contact_name');
            $generalmessage->contact_company = Input::get('contact_company');
            $generalmessage->contact_neworcurrent = Input::get('contact_neworcurrent');
            $generalmessage->contact_phone = Input::get('contact_phone');
            $generalmessage->contact_email = Input::get('contact_email');
            $generalmessage->contact_blurb = Input::get('contact_blurb');
            $generalmessage->contact_preferreddays = Input::get('contact_preferreddays');
            $generalmessage->contact_preferredtimes = Input::get('contact_preferredtimes');
            $generalmessage->save();

            // Sending notification email
            $vars = Input::all();

            Mail::send('(vendor).generalcontact::mail.message', $vars, function($message) {

                $message->to('(testemailaddress)', 'Chris Ricci');
                $message->subject('Hey! New Website General Contact Notification');

            }); 
        }
    }    
}

And lastly, the GeneralMessage model in the plugin, which I generated with the help of the Builder plugin on the backend. I'm not sure if it's redundant, but I added in the validation rules to this Model as well:

    <?php namespace (Vendor)\GeneralContact\Models;

use Model;

/**
 * Model
 */
class GeneralMessage extends Model
{
    use \October\Rain\Database\Traits\Validation;

    /**
     * @var string The database table used by the model.
     */
    public $table = '(vendor)_generalcontact_';

    /**
     * @var array Validation rules
     */
    public $rules = [
        'contact_name' => 'required',
        'contact_company' => 'nullable',
        'contact_neworcurrent' => 'nullable',
        'contact_phone' => 'required_without:contact_email',
        'contact_email' => 'required_without:contact_phone',
        'contact_blurb' => 'required',
        'contact_preferreddays' => 'nullable',
        'contact_preferredtimes' => 'nullable'
    ];
}

Any help is super-appreciated with this. :) Thank you for your time.

JeffGoldblum
JeffGoldblum

Do you have a full stack trace of the model? Also, you're don't need validation rules in the component if you already have them in the model, just populate the model from the input and then if you save their model with invalid data it will throw a validation exception and not save.

JeffGoldblum
JeffGoldblum

Also feel free to check out my easy forms plugin :)

mjauvin
mjauvin

If you remove the call to Mail::send(), do you still get that alert?

Can you show the mail template file?

CricciDisk
CricciDisk

Luke, thank you for such a quick response and that information regarding validation! Bear with me, but is the following what you were hoping to see? This is derived from Settings -> Event Log -> (Occurrence of the error) -> Raw output. let me know if you were hoping for something different. :)

Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getAttribute() on null in C:\xampp\htdocs\mccabes_2020main\vendor\erusev\parsedown-extra\ParsedownExtra.php:489
Stack trace:
#0 C:\xampp\htdocs\mccabes_2020main\vendor\erusev\parsedown-extra\ParsedownExtra.php(232): ParsedownExtra->processTag('<body style="fo...')
#1 C:\xampp\htdocs\mccabes_2020main\vendor\erusev\parsedown\Parsedown.php(276): ParsedownExtra->blockMarkupComplete(Array)
#2 C:\xampp\htdocs\mccabes_2020main\vendor\erusev\parsedown\Parsedown.php(39): Parsedown->lines(Array)
#3 C:\xampp\htdocs\mccabes_2020main\vendor\erusev\parsedown-extra\ParsedownExtra.php(46): Parsedown->text('<body style="fo...')
#4 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Parse\Markdown.php(103): ParsedownExtra->text('<body style="fo...')
#5 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Parse\Markdown.php(46): October\Rain\Parse\Markdown->parseInternal('<body style="fo...')
#6 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Parse\Markdown.php(74): October\Rain\Parse\Markdown->parse('<body style="fo...')
#7 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(221): October\Rain\Parse\Markdown->parseSafe('<body style="fo...')
#8 C:\xampp\htdocs\mccabes_2020main\modules\system\classes\MailManager.php(179): Illuminate\Support\Facades\Facade::__callStatic('parseSafe', Array)
#9 C:\xampp\htdocs\mccabes_2020main\modules\system\classes\MailManager.php(188): System\Classes\MailManager->render('<body style="fo...', Array)
#10 C:\xampp\htdocs\mccabes_2020main\modules\system\classes\MailManager.php(142): System\Classes\MailManager->renderTemplate(Object(System\Models\MailTemplate), Array)
#11 C:\xampp\htdocs\mccabes_2020main\modules\system\classes\MailManager.php(96): System\Classes\MailManager->addContentToMailerInternal(Object(Illuminate\Mail\Message), Object(System\Models\MailTemplate), Array, false)
#12 C:\xampp\htdocs\mccabes_2020main\modules\system\ServiceProvider.php(350): System\Classes\MailManager->addContentToMailer(Object(Illuminate\Mail\Message), 'mccabes.general...', Array, false)
#13 [internal function]: System\ServiceProvider->System\{closure}(Object(October\Rain\Mail\Mailer), Object(Illuminate\Mail\Message), 'mccabes.general...', Array, NULL, NULL)
#14 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Events\Dispatcher.php(233): call_user_func_array(Object(Closure), Array)
#15 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Events\Dispatcher.php(197): October\Rain\Events\Dispatcher->dispatch('mailer.beforeAd...', Array, true)
#16 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(221): October\Rain\Events\Dispatcher->fire('mailer.beforeAd...', Array, true)
#17 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Mail\Mailer.php(403): Illuminate\Support\Facades\Facade::__callStatic('fire', Array)
#18 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Mail\Mailer.php(77): October\Rain\Mail\Mailer->addContent(Object(Illuminate\Mail\Message), 'mccabes.general...', NULL, NULL, Array)
#19 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(221): October\Rain\Mail\Mailer->send('mccabes.general...', Array, Object(Closure))
#20 C:\xampp\htdocs\mccabes_2020main\plugins\mccabes\generalcontact\components\generalcontactform.php(72): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#21 C:\xampp\htdocs\mccabes_2020main\modules\cms\classes\ComponentBase.php(187): Mccabes\GeneralContact\Components\GeneralContactForm->onSend()
#22 C:\xampp\htdocs\mccabes_2020main\modules\cms\classes\Controller.php(848): Cms\Classes\ComponentBase->runAjaxHandler('onSend')
#23 C:\xampp\htdocs\mccabes_2020main\modules\cms\classes\Controller.php(739): Cms\Classes\Controller->runAjaxHandler('generalcontactf...')
#24 C:\xampp\htdocs\mccabes_2020main\modules\cms\classes\Controller.php(372): Cms\Classes\Controller->execAjaxHandlers()
#25 C:\xampp\htdocs\mccabes_2020main\modules\cms\classes\Controller.php(223): Cms\Classes\Controller->runPage(Object(Cms\Classes\Page))
#26 C:\xampp\htdocs\mccabes_2020main\modules\cms\classes\CmsController.php(50): Cms\Classes\Controller->run('contact')
#27 [internal function]: Cms\Classes\CmsController->run('contact')
#28 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(54): call_user_func_array(Array, Array)
#29 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('run', Array)
#30 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Cms\Classes\CmsController), 'run')
#31 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Route.php(169): Illuminate\Routing\Route->runController()
#32 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Router.php(658): Illuminate\Routing\Route->run()
#33 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#35 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#44 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#45 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#47 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#49 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Router.php(660): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#51 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Router.php(635): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#52 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Router.php(601): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#53 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Router\CoreRouter.php(20): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#54 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(176): October\Rain\Router\CoreRouter->dispatch(Object(Illuminate\Http\Request))
#55 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#56 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#57 C:\xampp\htdocs\mccabes_2020main\vendor\october\rain\src\Foundation\Http\Middleware\CheckForMaintenanceMode.php(24): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#58 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): October\Rain\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#60 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#61 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#62 C:\xampp\htdocs\mccabes_2020main\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#63 C:\xampp\htdocs\mccabes_2020main\index.php(43): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#64 {main}
CricciDisk
CricciDisk

mjauvin said:

If you remove the call to Mail::send(), do you still get that alert?

Can you show the mail template file?

mjauvin, thank you for an equally-quick response! You and Luke rock. :)

So I just commented out the "Mail::send()" portion of my component and tried submitting the frontend form again. I did not receive the error alert from the frontend or the backend, and the form saved to my builder plugin. We're getting somewhere! :)

Was this the mail template you were hoping to see? This is currently located at "plugins(vendor)\generalcontact\views\mail\message.htm". Pardon the syntax, it's been a long time since I've styled for an email and I'm sure this will change as I get things further developed. :)

<body style="font-size: 16px;">
    <p>Hello! We just received a new general contact message from our website.</p>

    <table style="width:100%; max-width:640px; border:1px solid black; border-collapse:collapse;">
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">From:</td> <td style="width:70%;"> {{ contact_name }}</td>
        </tr>
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">Company or Organization Name:</td> <td style="width:70%;">{{ contact_company }}</td>
        </tr>
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">New Customer?</td> <td style="width:70%;">{{ contact_neworcurrent }}</td>
        </tr>
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">Phone Number:</td> <td style="width:70%;">{{ contact_phone }}</td>
        </tr>
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">Email Address:</td> <td style="width:70%;">{{ contact_email }}</td>
        </tr> 
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">Preferred Contact Days:</td> <td style="width:70%;">{{ contact_preferreddays }}</td>
        </tr> 
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;">Preferred Contact Times:</td> <td style="width:70%;">{{ contact_preferredtimes }}</td>
        </tr>
        <tr>
            <td style="background-color:#ddd; border:1px solid black; padding:4px; font-weight:bold; width:30%;" colspan="2">Contact Message:</td>
        </tr>
        <tr>
            <td colspan="2" style="width:70%;">{{ contact_blurb }}</td>
        </tr>
    </table>
</body>
CricciDisk
CricciDisk

LukeTowers said:

Also feel free to check out my easy forms plugin :)

I may have to take you up on that offer. :) This is my first time exploring the coding world outside of HTML, CSS, and some basic Javascript/PHP!

mjauvin
mjauvin

Your view file is missing the header section (e. g.)

subject = "Contact Form Notification"
description = "Send Notification"
layout = "simple"
==
mjauvin
mjauvin

of course the layout name needs to be one you have defined

mjauvin
CricciDisk
CricciDisk

mjauvin said:

Your view file is missing the header section (e. g.)

subject = "Contact Form Notification"
description = "Send Notification"
layout = "simple"
==

Hi mjauvin, thank you for this information. To keep things as bug-free as possible, I went ahead and added a header section to my mail view that made use of your supplied information, with the layout set to the "default" mail layout in OctoberCMS. Unfortunately, after saving the file, refreshing the contact page, and resubmitting the form, I'm still encountering the same error.

I also went ahead and reviewed your supplied Mail-View documentation, but I'm still not seeing anything that looks out-of-place. :(

mjauvin
mjauvin

Try changing your mail view content to just a static string after the header to see if the error still happens

CricciDisk
CricciDisk

Woah, now we're REALLY getting somewhere. After removing all of my HTML and leaving it to just the template markup, the frontend form saved to both the backend AND sent over a test email. I'm thinking it's safe to say that there was something funky happening with the HTML in my mail view, though I'll experiment with a few different layouts to see if the problem emerges anywhere else. You saved the day--thank you!

Here is the trial code for reference. :)

subject = "Contact Form Notification"
description = "Send Notification"
layout = "default"
==
{{ contact_name }} {{ contact_company }} {{ contact_neworcurrent }} {{ contact_phone }} {{ contact_email }} {{ contact_preferreddays }} {{ contact_preferredtimes }} {{ contact_blurb }}
mjauvin
mjauvin

try just losing the "<body>" tag

mjauvin
mjauvin

keep in mind that the LAYOUT already contains the page structure (body, head, html tags) and the mail view should only contain the inner content.

For reference, an example layout looks like:

https://github.com/octobercms/october/blob/develop/modules/system/views/mail/layout-default.htm

Last updated

1-15 of 15

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.