How to modify the Contact Form in Dawn Theme?

Hello,

How can I make the following changes to my Contact Form?

  1. Make ‘Name’ and ‘Comment’ fields required.
  2. Remove ‘Phone Number’ field.

Thank you!

1 Like

Hi @sabtsmith

In order to achieve these, you need to edit the contact form code. To be on the safe side, I suggest you make a duplication of your theme before making any changes to it.

Please go to your Online Stores > Themes > Edit code > Sections > Contact-form.liquid

1. Remove ‘Phone Number’ field.

Remove this code from the file:


2. Make “name” filed required

Find the line that contains id=“ContactForm-name”
Replace this code


          

with the following code:

 

3. Make “comment” field required

Find the line with ‘templates.contact.form.comment’

Replace this code


      

with this one


      
    

I tested it in my store and it worked. Hope it helps.

2 Likes

@sabtsmith

oh sorry for that issue if possible to share your contact form code so i will update

Sure! It’s here ----

{{ ‘section-contact-form.css’ | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{{ section.settings.heading | escape }}

{%- form 'contact', id: 'ContactForm', class: 'isolate' -%} {%- if form.posted_successfully? -%}
{% render 'icon-success' %} {{ 'templates.contact.form.post_success' | t }}
{%- elsif form.errors -%}

{% render 'icon-error' %} {{ 'templates.contact.form.error_heading' | t }}

{%- endif -%}
{{ 'templates.contact.form.name' | t }}
{{ 'templates.contact.form.email' | t }} * {%- if form.errors contains 'email' -%} {{ 'accessibility.error' | t }} {% render 'icon-error' %}{{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }} {%- endif -%}
{{ 'templates.contact.form.phone' | t }}
{{- form.body -}} {{ 'templates.contact.form.comment' | t }}
{{ 'templates.contact.form.send' | t }}
{%- endform -%}

{% schema %}
{
“name”: “t:sections.contact-form.name”,
“tag”: “section”,
“class”: “section”,
“settings”: [
{
“type”: “text”,
“id”: “heading”,
“default”: “Contact form”,
“label”: “Heading”
},
{
“type”: “select”,
“id”: “color_scheme”,
“options”: [
{
“value”: “accent-1”,
“label”: “t:sections.all.colors.accent_1.label”
},
{
“value”: “accent-2”,
“label”: “t:sections.all.colors.accent_2.label”
},
{
“value”: “background-1”,
“label”: “t:sections.all.colors.background_1.label”
},
{
“value”: “background-2”,
“label”: “t:sections.all.colors.background_2.label”
},
{
“value”: “inverse”,
“label”: “t:sections.all.colors.inverse.label”
}
],
“default”: “background-1”,
“label”: “t:sections.all.colors.label”
},
{
“type”: “header”,
“content”: “t:sections.all.padding.section_padding_heading”
},
{
“type”: “range”,
“id”: “padding_top”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_top”,
“default”: 36
},
{
“type”: “range”,
“id”: “padding_bottom”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_bottom”,
“default”: 36
}
],
“presets”: [
{
“name”: “t:sections.contact-form.presets.name”
}
]
}
{% endschema %}

1 Like

@sabtsmith

thanks can you please try this code

{{ 'section-contact-form.css' | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

## {{ section.settings.heading | escape }}
{%- form 'contact', id: 'ContactForm', class: 'isolate' -%}
{%- if form.posted_successfully? -%}
{% render 'icon-success' %} {{ 'templates.contact.form.post_success' | t }}

{%- elsif form.errors -%}

## {% render 'icon-error' %} {{ 'templates.contact.form.error_heading' | t }}

- {{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }}

{%- endif -%}

{%- if form.errors contains 'email' -%}
<small>
{{ 'accessibility.error' | t }}
{% render 'icon-error' %}{{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }}
</small>
{%- endif -%}

{%- endform -%}

{% schema %}
{
"name": "t:sections.contact-form.name",
"tag": "section",
"class": "section",
"settings": [
{
"type": "text",
"id": "heading",
"default": "Contact form",
"label": "Heading"
},
{
"type": "select",
"id": "color_scheme",
"options": [
{
"value": "accent-1",
"label": "t:sections.all.colors.accent_1.label"
},
{
"value": "accent-2",
"label": "t:sections.all.colors.accent_2.label"
},
{
"value": "background-1",
"label": "t:sections.all.colors.background_1.label"
},
{
"value": "background-2",
"label": "t:sections.all.colors.background_2.label"
},
{
"value": "inverse",
"label": "t:sections.all.colors.inverse.label"
}
],
"default": "background-1",
"label": "t:sections.all.colors.label"
},
{
"type": "header",
"content": "t:sections.all.padding.section_padding_heading"
},
{
"type": "range",
"id": "padding_top",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_top",
"default": 36
},
{
"type": "range",
"id": "padding_bottom",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_bottom",
"default": 36
}
],
"presets": [
{
"name": "t:sections.contact-form.presets.name"
}
]
}
{% endschema %}
1 Like

Thank you! That appeared to work. Two follow-up questions:

  1. How do I add the asterisk to show that the ‘Name’ and ‘Comment’ fields are required, similar to how the ‘Email’ field appears?
  2. How can I change the label from ‘Comment’ to ‘Message’?

Thank you!

1 Like

Would love to see this answered as well, as I’m trying to figure out how to achieve the same. Did you manage to do it, @sabtsmith ? Thks in advance!

Yes! To make sure I give you the right answer, are you asking about the initial questions below…

  1. Make ‘Name’ and ‘Comment’ fields required.
  2. Remove ‘Phone Number’ field.

…or the follow up questions below:

  1. How do I add the asterisk to show that the ‘Name’ and ‘Comment’ fields are required, similar to how the ‘Email’ field appears?
  2. How can I change the label from ‘Comment’ to ‘Message’?

Hi and thank you for getting back to me. I meant the two follow up questions. Thanks!

Here you go!

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click Actions > Edit languages.

  3. Click the tab that includes the text that you want to change.

  4. Edit the text.

  5. Click Save.

More info is here

1 Like

Thank you so much, it worked! :folded_hands:

Do happen to know how I can add/remove the asterisks from the fields, depending on whether they’re mandatory or not?

Thank you once again!

Hello Ketan, I Would like to ask you the same. I have created a custom contact form. but I am unable to get a notification of the fields. I just got “name”, “email”, “country code” and “phone”

My code is this

{{ ‘section-contact-form.css’ | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{%- if section.settings.heading != blank -%}

{{ section.settings.heading }}

{%- else -%}

{{ 'templates.contact.form.title' | t }}

{%- endif -%} {%- liquid assign contact_form_class = 'isolate' if settings.animations_reveal_on_scroll assign contact_form_class = 'isolate scroll-trigger animate--slide-in' endif -%} {%- form 'contact', id: 'ContactForm', class: contact_form_class -%} {%- if form.posted_successfully? -%}

{% render 'icon-success' %} {{ 'templates.contact.form.post_success' | t }}

{%- elsif form.errors -%}

{% render 'icon-error' %} {{ 'templates.contact.form.error_heading' | t }}

{%- endif -%}
{{ 'templates.contact.form.name' | t }}
{{- 'templates.contact.form.email' | t }} * {%- if form.errors contains 'email' -%} {{ 'accessibility.error' | t }} {%- render 'icon-error' -%} {{- form.errors.translated_fields.email | capitalize }} {{ form.errors.messages.email -}} {%- endif -%}
{{ 'templates.contact.form.phone' | t }}
Indoor/Outdoor Sign
Indoor
Outdoor
Approximate size (length/height)
Tell us as much as you can about your new Custom Neon sign
Budget Idea
US Dollars
Canadian Dollars
Upload File

{% comment %}

{{- form.body -}} {{- 'templates.contact.form.comment' | t -}}
{% endcomment %}
{{ 'templates.contact.form.send' | t }}
{%- endform -%}

{% schema %}
{
“name”: “t:sections.contact-form.name”,
“tag”: “section”,
“class”: “section”,
“disabled_on”: {
“groups”: [“header”, “footer”]
},
“settings”: [
{
“type”: “inline_richtext”,
“id”: “heading”,
“default”: “Contact form”,
“label”: “Heading”
},
{
“type”: “select”,
“id”: “heading_size”,
“options”: [
{
“value”: “h2”,
“label”: “t:sections.all.heading_size.options__1.label”
},
{
“value”: “h1”,
“label”: “t:sections.all.heading_size.options__2.label”
},
{
“value”: “h0”,
“label”: “t:sections.all.heading_size.options__3.label”
}
],
“default”: “h1”,
“label”: “t:sections.all.heading_size.label”
},
{
“type”: “color_scheme”,
“id”: “color_scheme”,
“label”: “t:sections.all.colors.label”,
“default”: “background-1”
},
{
“type”: “header”,
“content”: “t:sections.all.padding.section_padding_heading”
},
{
“type”: “range”,
“id”: “padding_top”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_top”,
“default”: 36
},
{
“type”: “range”,
“id”: “padding_bottom”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_bottom”,
“default”: 36
}
],
“presets”: [
{
“name”: “t:sections.contact-form.presets.name”
}
]
}
{% endschema %}

Hello! I was wondering if you might be able to help me format the button on the contact form the say ‘SUBMIT’ and be in a heading font, not paragraph. I’m using the Dawn theme. Thanks in advance :slightly_smiling_face: