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

roger.creasy5931
roger.creasy5931

I have a submission form that sends form data via email. After the form is successfully handled (email is sent), the user is given an empty alert box. What causes this and how do I stop it?

oly2554
oly2554

Need a bit more info to help, do you have an example of the form code?

roger.creasy5931
roger.creasy5931

oly2554 Thanks for the reply.

Here is the form Partial:

<div class="row">
    <div class="col-lg-12">
        <form data-request="onInfoRequest" name="sentMessage" id="contactForm" novalidate="">
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Your Name *" id="name" required="" data-validation-required-message="Please enter your name.">
                        <p class="help-block text-danger"></p>
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control" placeholder="Your Email *" id="email" required="" data-validation-required-message="Please enter your email address.">
                        <p class="help-block text-danger"></p>
                    </div>
                    <div class="form-group">
                        <input type="tel" class="form-control" placeholder="Your Phone *" id="phone" required="" data-validation-required-message="Please enter your phone number.">
                        <p class="help-block text-danger"></p>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <textarea class="form-control" placeholder="Your Message *" id="message" required="" data-validation-required-message="Please enter a message."></textarea>
                        <p class="help-block text-danger"></p>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="col-lg-12 text-center">
                    <div id="success"></div>
                    <button type="submit" class="btn btn-xl">
                        Send Message
                    </button>

                </div>
            </div>
        </form>
    </div>
oly2554
oly2554

Sorry I can't see why from that you would be getting an empty array returned in an alert box. Can you link to the page where the error is happening?

roger.creasy5931
roger.creasy5931

Sorry, I should have done that to begin with.....

http://imageweaversmarketing.com/

Click on "contact" in the top-right to go to the partial.

Here is the php that handles the post:

   use Illuminate\Support\Facades\Mail;
   public function onInfoRequest() {
   $data = ['name' => 'test from function'];
   Mail::send('mail.inforequest', $data, function ($message) {
   $message->to('fake@hidden.com', 'Roger Creasy');

   });
}

Last updated

oly2554
oly2554

Nope sorry I can't see what is causing the error, however the is request failing so I would guess that there is an error in your PHP section if you comment out the stuff in your function and just put something like return "hello" does the error persist?

Sorry I can't be more help.

Last updated

roger.creasy5931
roger.creasy5931

oly2554 - Thanks so much for trying! I am at my day job right now. I'll try your return a string suggestion tonight. However, the email does get sent. This form sends the email to me - I got your tries. The form will eventually be a way for site visitors to request more info from our sales department (which is also me).

Thanks again for your help. When I figure this out, I'll post the solution here so it can maybe help others.

oly2554
oly2554

I assume you have a reason for doing the contact form this way but just incase you hadn't seen there are contact form plugins that work great such as https://octobercms.com/plugin/laminsanneh-flexicontact

Sorry for spamming you mail box and good luck figuring it out :)

roger.creasy5931
roger.creasy5931

Based on the suggestion by oly2554, I tried using the Flexi Contact plugin. I ended back at the AJAX handler not found issue.

I am at a loss. I have tried to have an email sent on a form response - should be super simple, but it is not. I may have to look for another Laravel CMS.

roger.creasy5931
roger.creasy5931

I solved the problem...sort of.

I created a route resource and controller to handle the request, then submitted the form to the resource. I am learning.

AlecSPB
AlecSPB

roger.creasy5931 said:

I solved the problem...sort of.

I created a route resource and controller to handle the request, then submitted the form to the resource. I am learning.

Hello Roger!!! I'm looking for a solution to this problem for quite some time. Write the code here, please. And yet, you tried to do the right validation for the $phone field?

1-11 of 11

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