1

Implementing the solution found on Bring Matrix Data Editing to the Front-End I've a matrix field that contains a P&T Dropdown field type

<select name="role_level[row_new_0][col_id_46]">
{options:role_level}
<option value="{option_value}"{selected}>{option_name}</option>
{/options:role_level}
</select>

This doesn't work (no options output), the author of the post adviced to hard-code the options

<select name="level_matrix[row_new_0][col_id_46]">
<option value="">Choose Level</option>
<option value="Entry Level">Entry Level</option>
<option value="Experienced">Experienced</option>
<option value="Manager">Manager</option>
<option value="Executive">Executive</option>
</select>

How can i make the selected option remain "selected"? (will be doing this on many other fields)

Thanks

  • Just posting a note here to let onlookers know that i'm still working on this for the time being (stuartmcd69 your code seems working.) I’ll post an update back here once i have something to share! – lincolnpixel Oct 14 '14 at 12:39
0

I got around this in a recent project by making the actual field in the entry a text field - the entries were ever only going to be editable via front end so a dropdown/select was redundant. Then using Low Variables, created a dropdown/select that I can call in when required. I actually created a few for my needs but could work for you.

Create form:

<select name="scrim_type" >
    {exp:low_variables:options var="lv_scrim_type"}
    <option value="{lv_scrim_type:data}"{selected}>{lv_scrim_type:data_label}</option>
    {/exp:low_variables:options}
</select>

-- This saves the selected option to the text field on save.

Edit Form

{exp:channel:form entry_id="segment_3"}
    <select  name="scrim_type" >
        {exp:low_variables:options var="lv_scrim_type"}
        <option value="{lv_scrim_type:data}" {if lv_scrim_type:data == scrim_type}selected{/if}>{lv_scrim_type:data_label}</option>
        {/exp:low_variables:options}
    </select>
{/exp:channel:form}

The "if" statement uses the entries value for the text field scrim_type to 'select' the active option.

Hope it helps :)

| improve this answer | |
0

Maybe I am missing something but you have to set the option that the person has selected to selected="selected". This answer seems too easy though. What am I missing?

You were correct to hard code the values.

| 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.