6

I have an Entries field that I need to have as a drop-down field in my front-end form. The code below is displaying the correct options, although after selecting and submitting the form, the tbdDesignerUrl-field is not populated with the selection in the entry.
It shows as nothing selected. (tbdDesignerUrl is the name of the Entires field I am trying to populate through the form and entry.designerUrl is the field I am using to select the entry in the options.)

{% set entries = craft.entries.section('designers') %}
  <select name="fields[tbdDesignerUrl]" id="fields[tbdDesignerUrl]">
    {% for entry in entries %}
     <option value="{{ entry.designerUrl }}">{{ entry.designerUrl }}</option>
    {% endfor %}
  </select>

Thanks for any help you can give! :)

8

Simply put, an Entries field is an array containing entry ids, and your form needs to send it that way.

Just replace name="fields[tbdDesignerUrl]" with name="fields[tbdDesignerUrl][]". That way the value gets submitted as an array.

Also replace value="{{ entry.designerUrl }}" with value="{{ entry.id }}", since we need the submitted value to be an entry id.

0

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.