How do I use set_select with database values? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How do I use set_select with database values? (/showthread.php?tid=18129) |
How do I use set_select with database values? - El Forum - 04-26-2009 [eluser]RS71[/eluser] Hey, I was using form helpers to build my selects but I think I'm gonna switch typing them out on HTML. What I had before: Code: <?= form_dropdown('sex', $sex_options, set_value('sex', (isset($database['basic_info']->sex)) ? $database['basic_info']->sex : '')); ?> I'm having some problem understanding how to use database values with set_selects (uh.. its pretty late at night heh) Could somebody assist me? Basic, check if there is a validation error value, if not use a database value, if not use default (which in the code I posted above for example is '') Thanks in advance How do I use set_select with database values? - El Forum - 04-26-2009 [eluser]Thorpe Obazee[/eluser] Quote: This is what I usually do. I am not fond of form helpers. How do I use set_select with database values? - El Forum - 04-26-2009 [eluser]RS71[/eluser] Hey thanks for the tip I was thinking, what if I edited the set_select function? Here is the default code: Code: // -------------------------------------------------------------------- Perhaps a fourth parameter used for database values and modifying the first if statement? How do I use set_select with database values? - El Forum - 04-26-2009 [eluser]Thorpe Obazee[/eluser] I didn't look at your code but nothing prevents you from 'extending' it. How do I use set_select with database values? - El Forum - 04-29-2009 [eluser]taro uma[/eluser] I am doing this to create a dropdown menu of years, starting with the current year and looping to 10+ years. Is there a way to use the form helper set_select() with this so if the form is reloaded (like with errors) this dropdown remembers the user selected option? currently I have it set so that the current year is selected, but can't see a way to use set_select() with it. Code: <?php |