0

I'm working with the P&T contact form plugin: https://github.com/pixelandtonic/ContactForm

And I can't figure out how to add additional fields to my email, where do I add the additional field to the email template?

Thanks is advance.

MORE INFO:

Error Message:

Internal Server Error
Property "Craft\ContactFormModel.company" is not defined.

HTML Email Form:

$email->body = "Your Name: ".$message->fromName."\n\nCompany:\n\n".$message->company."Email Address: ".$message->fromEmail."\n\nPhone Number: ".$message->phone."\n\nRequests: ".$message->message;
2

I'd start by reading the "Adding Additional Fields" part of the docs. ;)

  • I've read the "Adding Additional Fields" and they don't appear on my email. The only fields that are on my email are: email and message. Also, to add: I have message[phone] and message[company] on my form, but they don't submit to my email. – Zachary Jan 16 '15 at 21:42
  • Can you edit your original question and include the email form HTML? – Brad Bell Jan 16 '15 at 22:22
  • Wait... so you're modifying the plugin's PHP code? If you follow the directions I linked to, that won't be necessary. – Brad Bell Jan 16 '15 at 22:35
  • Without, the only fields that are displayed is name, email and message. I must be missing something here. I've also did a copy-and-paste of the instruction with the same results. – Zachary Jan 16 '15 at 22:42
0

I was having similar issues and was able to add some additional fields per the documentation Brad had mentioned. However, I found this post and it helped me print out the name and email address into the body of the email. Hope this helps someone.

0

@Clint Hubbard jr If you need the email and the fromName in the html message body this can also be done without an extra plugin, using jQuery. Insert two extra hidden fields:

<input id="body_name"type="hidden" name="message[Name]" value="">
<input id="body_email"type="hidden" name="message[Email]" value="">

Use the standard fields in the contact form:

<input id="fromName" type="text" name="fromName" required >
<input id="fromEmail" type="email" name="fromEmail" required >

Then jQuery:

<script>
$("#fromName").change(function() {
var myText = document.getElementById("fromName").value;
    $('#body_name').val(myText);
});
$("#fromEmail").change(function() {
    var myText = document.getElementById("fromEmail").value;
    $('#body_email').val(myText);
});
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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