I use safecracker and I want to edit a relationship field. How can I limit the options within the <select> to just a limited number of options?
Usually we do this
<label>The label:</label>
{custom_fields}
{if relationship}
<select id="{our_field}" name="{our_field}">
{options}
<option value="{option_value}"{selected}>{option_name}</option>
{/options}
</select>
{/if}
{/custom_fields}And this will list all relationship entries in the dropdown and shows the selected. Perfect.
Interesting enough, this would do the same
{field:our_field}
But for some reason I don’t want the user to be able to change the dropdown value. In this case I show the value of the relationship field and have the above code for the dropdown in a hidden div. Only this way I get the value written back into the db.
But now I want to have only 3 dropdown values (out of 10) in the < select >. I know ways how to pick those with an embed. But there is no way to write the selected value in to the db then. I tried many ways.
It seems that Safecracker only writes values into the db when we use the code like above. As soon as we construct a dropdown field “by hand” and want to bring the selected value into the db, we fail.
I thought what is reported here is solved in 2.3.1. There is a bug report for 2.2.2 with a fix here. A fix we can not find incorporated in 2.3.1. If we insert it in 2.3.1 we still can not save a value from a self written <select>. Only the full Safecracker code like above will work.
Can someone tell me how I would bring a selected value in a relationship field with a <select> that I limit, let’s say from 10 <options> to only 3? (The options limit according to the member level of the logged in member.
Help would be appreciated.