Sending request by mail in keystonejs to index.js

I have a contact form that I added to my index.jade file and I am trying to send a post request to / route using the following code in a jade template that renders fine.

if enquirySubmitted
 .row
    h3 Thanks for getting in touch.
else
  .row
    form.contact-form(method="post" )
         input(type='hidden', name='action', value='contact')
        .col-lg-4.col-sm-4(class=validationErrors.name ? 'has-error' : null)
          input.form-control.input-box(type='text', name='name.full', value=formData['name.full'], placeholder='Your Name')
        .col-lg-4.col-sm-4
          input.form-control.input-box(type='email', name='email', value=formData.email, placeholder='Your Email')
        .col-lg-4.col-sm-4
          div(class=validationErrors.enquiryType ? 'has-error' : null)
          input.form-control.input-box(type='text', name='enquiryType' value=formData.enquiryType)
      .col-md-12(class=validationErrors.message ? 'has-error' : null)
      .col-md-12
        textarea.textarea-box(name='message')= formData.message
      button(type='submit') Send Message

      

Here is the post code in index.js file

    locals.section = 'contact';
locals.formData = req.body || {};
locals.validationErrors = {};
locals.enquirySubmitted = false;

// On POST requests, add the Enquiry item to the database
view.on('post', { action: 'contact' }, function(next) {

    console.log('here');

    var newEnquiry = new Enquiry.model(),
        updater = newEnquiry.getUpdateHandler(req);

    updater.process(req.body, {
        flashErrors: true,
        fields: 'name, email, phone, message',
        errorMessage: 'There was a problem submitting your enquiry:'
    }, function(err) {
        if (err) {
            locals.validationErrors = err.errors;
        } else {
            locals.enquirySubmitted = true;
        }
        next();
    });

});

      

The problem I am running into is that there are no errors on the screen, or "here" to indicate that the submit request is being accepted on the backend. I have not been able to resolve this issue and am confused about what else I need to get the contact form to work. Looking at the test track didn't help. Also the index.js file is inroutes/views/index.js

+3


source to share





All Articles