0

I have this code in my safecracker form

<select class="span2" data-title="Help" data-placement="right" data-trigger="focus" data-content="{instructions:gender}" disabled id="gender">
 {options:gender}
   <option value="{option_value}" {selected}>{option_name}</option>
 {/options:gender}
</select>

genders is a relationship field. According to the documentation, I should be able to generate options for a select field using this syntax

<select name="my_field_name">
        {options:my_field_name}
                <option value="{option_value}"{selected}>{option_name}</option>
        {/options:my_field_name}
</select>

This doesn't work for me.

However, using

{field:gender}

works but outputs a select dropdown. I don't want this since I want to specify some attributes for the select tag as you can see above.

Any idea why this is the case?

I am using EE 2.5.5

1
1

You can try like this code example:

{custom_fields}
    {if relationship AND field_name == 'gender'}
        <select id="{field_name}" name="{field_name}[data][]">
            {options}
                <option value="{option_value}"{selected}>{option_name}</option>
            {/options}
        </select>
    {/if}
{/custom_fields}

I hope, it would work for you.

2
  • In my case, I don't think I need [data][]. I got an error. So I removed and it worked for me. Jul 16 '13 at 8:17
  • glad to know it. Jul 16 '13 at 8:27

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.