0

I currently have this dropdown on a front-end form, the problem I'm having is that it's saving the value where I really want to use the label in my templates such as United Kingdom instead of unitedKingdom. Is this something I should be changing in my Dashboard/Front-end/Dropdown?

        <div class="form-group">
          <label>Location</label>
          <select class="form-control" id="listingType" name="fields[location][]" required>
            {% set locationField = craft.fields.getFieldbyHandle('location') %}
            {% for option in locationField.settings.options %}
            <option value="{{ option.value }}">
              {{ option.label }}
            </option>
            {% endfor %}
          </select>
        </div>

Front End

{{ entry.author.location|ucwords }}

  • 1
    I don't get the question, you do want to have the label distributed in the frontend template, as you do with .label. You would use the value only for Form submission...as you do as well...I am confused 🤔 – HendrikEng Dec 12 '18 at 0:35
  • 1
    It seems he wants the value of the options to be the label. So both the label and value are the same. That would be a change in the dashboard. If you are manually setting all of the options, you should be able to set what the value is. – Indigo Viking Dec 12 '18 at 2:06
1

The value of dropdown fields are set in the dashboard. How to set the value is dependent on the form plugin or craft field type you are using.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.