ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker Select Menu - No no-value option available

June 25, 2012 2:21pm

Subscribe [3]
  • #1 / Jun 25, 2012 2:21pm

    Genevieve

    52 posts

    I’m using Safecracker on a site, and have a related entries field as a select menu, but the menu doesn’t generate a “Select Option” at the top of the list, which basically requires a user to either select a related entry or else the top entry is used by default. We want users to have the option of leaving the related entries field blank. So how do I get that top “no-value” option to show up at the top of the related entries list?

    For reference: the code I’m using for the related entries list is this:

    {custom_fields}
     {if relationship}
     <label for="{field_name}">{if required}* {/if}{field_label}</label>
            {if field_instructions}{field_instructions}{/if}
      
                    <select id="{field_name}" name="{field_name}">
                            {options}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                            {/options}
                    </select>
            {/if}
    {/custom_fields}
  • #2 / Jun 25, 2012 3:03pm

    Rob Allen

    3105 posts

    Hmm would have thought the option should be there.

    have you tried adding a no value option:

    <option value="">--Please select--</option>
    {options}
    <option value="{option_value}"{selected}>{option_name}</option>
    {/options}
  • #3 / Jun 26, 2012 2:27pm

    Genevieve

    52 posts

    Thanks, bluedreamer! Just smack me and say DUH! 😊 I should’ve been able to figure that one out. I appreciate it!

  • #4 / Jun 26, 2012 4:18pm

    Shane Eckert

    7174 posts

    Hey Genevieve,

    I am glad to see that Rob was able to help you out!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases