<p>This ended up being a css issue. In the CSS I had to create the following rule.</p>

<pre><code>input[type="text"].hidden { display: none; }
</code></pre>

CC BY-SA 3.0
2016-07-12T08:59:29.613Z
2016-07-12T08:59:29.613Z
Dan Lee
<p>In the Address section I have been defining UK counties to populate the State field when a Country is selected. I noticed that there is a standard text input when there is no defined states/regions/areas for a country and a drop down field for states when there is defined states. </p>

<p>When a country like the US or the UK is selected both fields are shown however ideally it should only be the dropdown. See image of the problem:</p>

<p><img src="https://i.sstatic.net/fOKke.png" alt="screenshot"></p>

<p>Is there any logic that can be added to toggle it on/off ?</p>

<pre><code>&lt;label for="{{ modelName }}-state"&gt;County / State / Region&lt;/label&gt;

{% set options = (model and states[model.countryId] is defined ? states[model.countryId] : []) %}
&lt;select id="{{ modelName }}-stateId" data-modelname="{{ modelName }}" class="address-stateId u-full-width {% if options|length == 0 or (model and model.stateName) %}hidden{% endif %}" name="{{ modelName }}[stateValue]"&gt;
  {% for key, option in options %}
    {% set optionValue = (model ? model.stateId : '') %}
    &lt;option value="{{ key }}" {% if key == optionValue %}selected{% endif %}&gt;{{ option }}&lt;/option&gt;
  {% endfor %}
&lt;/select&gt;

&lt;input type="text" data-modelname="{{ modelName }}" id="{{ modelName }}-stateName" class="address-stateName {% if options|length &gt; 0 or (model and model.stateId) %}hidden{% endif %} u-full-width" {% if model and model.stateName %}name="{{ modelName }}[stateValue]" value="{{ model.stateName}}"{% endif %}&gt;
</code></pre>

<plugin-craftcommerce>
Craft Commerce: Duplicate Input for Address State?
# Craft Commerce: Duplicate Input for Address State?

(Asked by: username_0 on 2016-06-29)

In the Address section I have been defining UK counties to populate the State field when a Country is selected. I noticed that there is a standard text input when there is no defined states/regions/areas for a country and a drop down field for states when there is defined states. 
When a country like the US or the UK is selected both fields are shown however ideally it should only be the dropdown. See image of the problem:

Is there any logic that can be added to toggle it on/off ?
County / State / Region

{% set options = (model and states[model.countryId] is defined ? states[model.countryId] : []) %}

  {% for key, option in options %}
    {% set optionValue = (model ? model.stateId : '') %}
    {{ option }}
  {% endfor %}

**Tags:** plugin-craftcommerce

---

## 1 answers

### Answer by username_0 on 2016-07-12. Score: 0 | Accepted answer

This ended up being a css issue. In the CSS I had to create the following rule.
input[type="text"].hidden { display: none; }


---

