Answers.Body: <p>I'd start by reading the "<a href="https://github.com/pixelandtonic/ContactForm#adding-additional-fields" rel="nofollow">Adding Additional Fields</a>" part of the docs. ;)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-16T21:42:59.050Z
Answers.Text: 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.
Answers.UserDisplayName: Zachary
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-16T22:22:03.337Z
Answers.Text: Can you edit your original question and include the email form HTML?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-16T22:35:13.190Z
Answers.Text: Wait... so you're modifying the plugin's PHP code? If you follow the directions I linked to, that won't be necessary.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-16T22:42:48.923Z
Answers.Text: 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.
Answers.UserDisplayName: Zachary
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-16T18:24:39.030Z
Answers.LastActivityDate: 2015-01-16T18:24:39.030Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>I was having similar issues and was able to add some additional fields per the documentation Brad had mentioned. However, I found this <a href="https://github.com/craftcms/contact-form/issues/72" rel="nofollow noreferrer">post</a> and it helped me print out the name and email address into the body of the email. Hope this helps someone.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-09T03:51:00.440Z
Answers.LastActivityDate: 2018-04-09T03:51:00.440Z
Answers.UserDisplayName: Clint Hubbard Jr
Answers.Body: <p>@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:</p>
  
  <pre><code>&lt;input id="body_name"type="hidden" name="message[Name]" value=""&gt;
  &lt;input id="body_email"type="hidden" name="message[Email]" value=""&gt;
  </code></pre>
  
  <p>Use the standard fields in the contact form:</p>
  
  <pre><code>&lt;input id="fromName" type="text" name="fromName" required &gt;
  &lt;input id="fromEmail" type="email" name="fromEmail" required &gt;
  </code></pre>
  
  <p>Then jQuery:</p>
  
  <pre><code>&lt;script&gt;
  $("#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);
  });
  &lt;/script&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-09T07:49:23.957Z
Answers.LastActivityDate: 2018-04-09T07:49:23.957Z
Answers.UserDisplayName: noregt
Answers.Body: <p>I am a few years late, but I think your problem may be that you are labeling your message body with <code>name="message"</code>, instead of <code>name="message[body]"</code> as you should if you use custom fields. This way, you should not be coding PHP yourself.</p>
  
  <p>Here is an example with a default field, a custom field and the message body field:</p>
  
  <pre><code>&lt;input type="text" id="from-name" type="text" name="fromName" value="{{ message.fromName ?? '' }}"&gt;
  
  &lt;input type="text" id="phone" type="tel" name="message[Phone]"&gt;
  
  &lt;textarea id="message" name="message[body]"&gt;{{ message.message ?? '' }}&lt;/textarea&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-09T12:13:56.797Z
Answers.LastActivityDate: 2020-06-09T12:13:56.797Z
Answers.UserDisplayName: Martijn Luyckx
Body: <p>I'm working with the P&amp;T contact form plugin:
  <a href="https://github.com/pixelandtonic/ContactForm" rel="nofollow">https://github.com/pixelandtonic/ContactForm</a></p>
  
  <p>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?</p>
  
  <p>Thanks is advance.</p>
  
  <p>MORE INFO:</p>
  
  <p>Error Message:</p>
  
  <pre><code>Internal Server Error
  Property "Craft\ContactFormModel.company" is not defined.
  </code></pre>
  
  <p>HTML Email Form:</p>
  
  <pre><code>$email-&gt;body = "Your Name: ".$message-&gt;fromName."\n\nCompany:\n\n".$message-&gt;company."Email Address: ".$message-&gt;fromEmail."\n\nPhone Number: ".$message-&gt;phone."\n\nRequests: ".$message-&gt;message;
  </code></pre>
  
Tags: <plugin-contactform>
Title: Adding additional custom fields to Contact Form Plugin from Pixel & Tonic
ThreadText: # Adding additional custom fields to Contact Form Plugin from Pixel & Tonic
  
  (Asked by: username_0 on 2015-01-16)
  
  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;
  
  ```
  
  **Tags:** plugin-contactform
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2015-01-16. Score: 2
  
  I'd start by reading the "[Adding Additional Fields](https://github.com/pixelandtonic/ContactForm#adding-additional-fields)" part of the docs. ;)
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: Can you edit your original question and include the email form HTML?  
  > **username_1**: Wait... so you're modifying the plugin's PHP code? If you follow the directions I linked to, that won't be necessary.  
  > **username_0**: 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.  
  
  ---
  
  ### Answer by username_4 on 2020-06-09. Score: 1
  
  I am a few years late, but I think your problem may be that you are labeling your message body with `name="message"`, instead of `name="message[body]"` as you should if you use custom fields. This way, you should not be coding PHP yourself.
  
  Here is an example with a default field, a custom field and the message body field:
  
  ```
  <input type="text" id="from-name" type="text" name="fromName" value="{{ message.fromName ?? '' }}">
  
  <input type="text" id="phone" type="tel" name="message[Phone]">
  
  <textarea id="message" name="message[body]">{{ message.message ?? '' }}</textarea>
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2018-04-09. Score: 0
  
  I was having similar issues and was able to add some additional fields per the documentation username_1 had mentioned. However, I found this [post](https://github.com/craftcms/contact-form/issues/72) and it helped me print out the name and email address into the body of the email. Hope this helps someone.
  
  
  ---
  
  ### Answer by username_3 on 2018-04-09. Score: 0
  
  @username_2 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>
  
  ```
  
  
  ---
  
  