<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: suthanalley</title>
    <description>The latest articles on DEV Community by suthanalley (@suthanalley).</description>
    <link>https://dev.to/suthanalley</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F51244%2F762ec44e-8e02-4cd6-9323-361a65c82ccd.png</url>
      <title>DEV Community: suthanalley</title>
      <link>https://dev.to/suthanalley</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suthanalley"/>
    <language>en</language>
    <item>
      <title>How to Add Custom Fields to Magento 2 Contact Page</title>
      <dc:creator>suthanalley</dc:creator>
      <pubDate>Tue, 20 Feb 2018 07:36:56 +0000</pubDate>
      <link>https://dev.to/suthanalley/how-to-add-custom-fields-to-magento-2-contact-page--3kb</link>
      <guid>https://dev.to/suthanalley/how-to-add-custom-fields-to-magento-2-contact-page--3kb</guid>
      <description>&lt;p&gt;Firstly create a module&lt;/p&gt;

&lt;p&gt;create module.xml in app/code/Magenticians/Modulecontact/etc and put the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0"?&amp;gt;
&amp;lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"&amp;gt;
&amp;lt;module name="Magenticians_Modulecontact" setup_version="1.0.1"&amp;gt;
&amp;lt;/module&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For module registration, create registration.php in app/code/Magenticians/Modulecontact and put the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Magenticians_Modulecontact',
__DIR__
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now override and add new field in Magento 2 contact form.&lt;/p&gt;

&lt;p&gt;Copy form.phtml file from the vendor/magento/module-contact/view/frontend/templates and paste in app/code/Magenticians/Modulecontact/view/frontend/templates.&lt;br&gt;
To add a new field to the contact form, open form.phtml file and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="field subject required"&amp;gt;
             &amp;lt;label class="label" for="subject"&amp;gt;&amp;lt;span&amp;gt;&amp;lt;?php /* @escapeNotVerified */ echo __('Subject') ?&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/label&amp;gt;
             &amp;lt;div class="control"&amp;gt;
                  &amp;lt;input name="subject" id="subject" title="&amp;lt;?php /* @escapeNotVerified */ echo __('Subject') ?&amp;gt;" value="" class="input-text" type="text" data-validate="{required:true}"/&amp;gt;
             &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Complete Guide: &lt;a href="https://magenticians.com/add-custom-field-in-magento-2-contact-page/"&gt;https://magenticians.com/add-custom-field-in-magento-2-contact-page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>php</category>
    </item>
  </channel>
</rss>
