Welcome Guest, Not a member yet? Register   Sign In
Repopulate select menus in 1.7
#1

[eluser]Sander Versluys[/eluser]
I've searched the forums and it's been asked before but since 1.7 the validation library has changed, I can't get it to work.

Code:
<select name="myselect">
  <option value="one" &lt;?php echo set_select('myselect', 'one', TRUE); ?&gt; >One</option>
  <option value="two" &lt;?php echo set_select('myselect', 'two'); ?&gt; >Two</option>
  <option value="three" &lt;?php echo set_select('myselect', 'three'); ?&gt; >Three</option>
</select>

This code is from the docs. I do not understand how the function can know which option to select. Can somebody explain this to me...?

Here's an example of what I'm trying todo:

Code:
<select name="level">
  <option value="0" &lt;?= set_select('level', '0'); ?&gt; >Gebruiker</option>
  <option value="1" &lt;?= set_select('level', '1'); ?&gt; >Partner</option>
  <option value="2" &lt;?= set_select('level', '2'); ?&gt; >Administrator</option>
</select>

In my controller I pass the object $user, wich has the property 'level', to the view. The option with the same level as in the object should be selected.

Any help would be greatly appreciated! Thanks!


Messages In This Thread
Repopulate select menus in 1.7 - by El Forum - 11-06-2008, 10:56 AM
Repopulate select menus in 1.7 - by El Forum - 11-06-2008, 05:24 PM
Repopulate select menus in 1.7 - by El Forum - 11-06-2008, 05:48 PM
Repopulate select menus in 1.7 - by El Forum - 11-07-2008, 01:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB