Could you please help to add a new custom field in Magento 2 contact form.

  • I hope my answer will solve your query. Jun 27, 2018 at 9:25

1 Answer 1


Open your form.phtml file.


Then add mycustomfield field to this contact form:

<div class="field mycustomfield required">
    <label class="label" for="mycustomfield"><span><?php /* @escapeNotVerified */ echo __('my custom field') ?></span></label>
    <div class="control">
        <input name="mycustomfield" id="mycustomfield" title="<?php /* @escapeNotVerified */ echo __('my custom field') ?>" value="" class="input-text" type="text" data-validate="{required:true}"/>

Add the above field in the form.

Go to MARKETING > Communication > Email Templates in the Magento Admin section. Click "Add New Template" and from the "Template" dropdown box select "Contact Form" then "Load Template". Under template content you can add your custom field:

Add your new field as per your requirement. it should looks like this:

{{trans "My Custom Field: %mycustomfield" mycustomfield=$data.mycustomfield}}
{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Phone Number: %telephone" telephone=$data.telephone}}
{{trans "Comment: %comment" comment=$data.comment}}

Enter a new name under "Template Name" to save your new Template and click on "Save Template". Now we need to tell Magento to use this new template for the Contact form.

Go to STORES -> Settings -> Configuration -> General -> Contacts and select "Contacts". Under "Email Options",

Select your new template under the "Email Options" -> "Email Template" dropdown box.

Click on "Save Config".

  • i have tried this solution and working fine but i have trying the get the Attachment file but Attachment file is not showing.But Only showing the file name Please help me. Feb 16, 2020 at 5:08
  • Please check screen-short prnt.sc/r2yo9s , Please help me Feb 16, 2020 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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