Welcome to Discussion Forum, where you can ask questions and receive answers from other members of the community.

How To Add Custom Fields to Magento 2 Contact Page

0 like 0 dislike
Firstly create a module
create module.xml in app/code/Magenticians/Modulecontact/etc and put the code:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magenticians_Modulecontact" setup_version="1.0.1">
For module registration, create registration.php in app/code/Magenticians/Modulecontact and put the code:
Now override and add new field in Magento 2 contact form.
Copy form.phtml file from the vendor/magento/module-contact/view/frontend/templates and paste in app/code/Magenticians/Modulecontact/view/frontend/templates.
To add a new field to the contact form, open form.phtml file and add the following code:
<div class="field subject required">
             <label class="label" for="subject"><span><?php /* @escapeNotVerified */ echo __('Subject') ?></span></label>
             <div class="control">
                  <input name="subject" id="subject" title="<?php /* @escapeNotVerified */ echo __('Subject') ?>" value="" class="input-text" type="text" data-validate="{required:true}"/>
asked Oct 30, 2018 in Magento by suthan

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

Related questions

0 like 0 dislike
0 answers 40 views
1 like 0 dislike
1 answer 427 views
427 views asked Mar 6, 2017 in Magento by harsh (8,710 points)
0 like 0 dislike
0 answers 3,366 views
3,366 views asked May 1, 2017 in Magento by harsh (8,710 points)
0 like 0 dislike
0 answers 404 views
1 like 0 dislike
0 answers 24 views
24 views asked Mar 31, 2017 in Magento by harsh (8,710 points)