Trouble adding a mailing address field. Any ideas?

Jamie_MacDonal1
New Member
2 0 0

I kind of thought this might be simple but I guess not.
Is this a limitation of using a theme (Capital) or just that 
I am not a coder and out of my league?

Screen Shot 2021-04-15 at 10.30.25 AM.jpg


Here is my horrible attempt at the code:

<div class="form-field grid-item-50">
        {% assign name_attr = 'page.contact.address' | t | handle %}
        <label for="ContactFormAddress" class="form-label" aria-label="{{ 'page.contact.address' | t }}">
          <span class="form-field-title">{{ 'page.contact.address' | t }}</span>
          <input type="address" id="ContactFormAddress" class="form-input form-full" name="contact[{{ name_attr }}]" placeholder="{{ 'page.contact.address_placeholder' | t }}" value="{% if form[name_attr] %}{{ form[name_attr] }}{% elsif customer %}{{ customer.address }}{% endif %}">
        </label>
      </div>


I simply copied another form field and changed values from PHONE to ADDRESS

I hope someone can offer some insight.
Thank you!

0 Likes
TylerFSG
New Member
5 0 0

You're missing the text translations for page.contact.address and page.contact.address_placeholder in your language file.  You would need to update the json in your language file to add these values.  The other option is just to hardcode the text values you want.

<div class="form-field grid-item-50"> <label for="ContactFormAddress" class="form-label" aria-label="Address"> <span class="form-field-title">Address</span> <input type="address" id="ContactFormAddress" class="form-input form-full" name="contact[{{ name_attr }}]" placeholder="Enter your address" value="{% if form[name_attr] %}{{ form[name_attr] }}{% elsif customer %}{{ customer.address }}{% endif %}"> </label> </div>

 

0 Likes