<p>Craft saves only the option value of a field, not the option description. After saving and editing again, it loops trough all the option values and compare it with the saved value. If it matchs it selects the first option. </p>

<p>You always need to have unique values. For example you can use 5fix and 5var as option values. If you need different outputs in your frontend template, you can use a switch case like this (code is untested, but should work):</p>

<pre><code>{% switch entry.field %}
  {% case "5fix" %}
    Fixed 5%
  {% case "5var" %}
    Variable 5% 
{% endswitch %}
</code></pre>

CC BY-SA 3.0
2016-02-23T21:08:49.307Z
2016-02-23T21:08:49.307Z
Tom Bauer
<p>I have a drop-down field in the CP - It represents a range of numbers that are based either a percent or a fixed number.</p>

<p>For example, a choice could be <code>Fixed 5%</code> or a choice could be <code>Variable 5%</code>
In either case, the value of my field is <code>5.00</code> for both options. The label is different, one says "Fixed" the other says "Variable".</p>

<p>It seems that this is a bad approach as I will usually get the first match based on value. </p>

<p>Let's say I have <code>Fixed 5%</code> listed first in my drop down field, but I actually choose <code>Variable 5%</code>. Currently, I am getting <code>Fixed 5%</code> as the selected option instead of <code>Variable 5%</code>. </p>

<p>I'm not sure how I can set up this field correctly so that Craft can see what I have chosen correctly. Perhaps there is a better way to setting up my drop down?</p>

<fieldtypes><drop-down>
How can I get the correct label of a dropdown that has matching values?
# How can I get the correct label of a dropdown that has matching values?

(Asked by: username_0 on 2016-02-23)

I have a drop-down field in the CP - It represents a range of numbers that are based either a percent or a fixed number.

For example, a choice could be `Fixed 5%` or a choice could be `Variable 5%`
In either case, the value of my field is `5.00` for both options. The label is different, one says "Fixed" the other says "Variable".

It seems that this is a bad approach as I will usually get the first match based on value.

Let's say I have `Fixed 5%` listed first in my drop down field, but I actually choose `Variable 5%`. Currently, I am getting `Fixed 5%` as the selected option instead of `Variable 5%`.

I'm not sure how I can set up this field correctly so that Craft can see what I have chosen correctly. Perhaps there is a better way to setting up my drop down?

**Tags:** fieldtypes, drop-down


---

## 1 answers

### Answer by username_1 on 2016-02-23. Score: 2 | Accepted answer

Craft saves only the option value of a field, not the option description. After saving and editing again, it loops trough all the option values and compare it with the saved value. If it matchs it selects the first option. 
You always need to have unique values. For example you can use 5fix and 5var as option values. If you need different outputs in your frontend template, you can use a switch case like this (code is untested, but should work):
{% switch entry.field %}
  {% case "5fix" %}
    Fixed 5%
  {% case "5var" %}
    Variable 5% 
{% endswitch %}


---

