1

I have a Select Dropdown field named Type belonging to a Channel. Inside I created a Value / Label menu.

I would like to print the values ​​in a Select in front-end.

Below I put my code that does NOT work.

From the documentation it seems to me that my code is correct. I forgot something?

<div class="form-group">
    <label>Tipologia</label>
    <select class="form-control" name="tipologia">
        <option>Tutti i comuni</option>
        {field_name}
        <option value="{field_name}">{field_name}</option>
        {/field_name}
    </select>
</div>

Thanks for support.

3

You are using this inside a channel entry loop, correct? If not, you need to be.

And you might also try using the other field segements:

{exp:channel:entries
    channel="my_channel_with_select_field"
    limit="1"
    dynamic="no"
    entry_id="the_entry_id_of_the_entry_i_want_to_output"}

    {select_field_name}
    Field value : {select_field_name:value} <br/>
    Field label : {select_field_name:label}
    {/select_field_name}

{/exp:channel:entries}

Just to make sure you aren't confused, this will output the selected value for a specific entry in that channel. If you are looking to output multiple values selected for an entry, you need to use a Multiselect Dropdown, not a regular select. And lastly, if you are looking to output this in a form, and you want to output all options the field has regardless of any entry in the channel, you need to use the channel form tag to do so:

https://docs.expressionengine.com/latest/channel/channel_form/index.html#other-channel-fields

| improve this answer | |
  • Hello, thanks for your quick reply. I'm not inside a channel. I just want to generate a Select HTML with the values ​​that contains my custom field. Just as written in the documentation at the link below. Link: docs.expressionengine.com/latest/fieldtypes/select.html The custom field is the same as that written in the documentation. I want to print all the Value contained in the custom field. – Alessandro Dec 28 '18 at 10:42
  • 1
    Field types and field definitions simply define what you can store in a channel - they don't store any data themselves. So if you have defined your custom field, the only way to have it populate a form is to store some values in a channel entry and then recall it as @jrothafer notes. If you just want to pre-define the content of the select / option field, a better bet would be to store the values you want in a template partial and recall it in similar fashion to how you show it in your example. More here: docs.expressionengine.com/latest/cp/design/template_partials/… – JCOGS Design Dec 28 '18 at 11:55

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.