Welcome Guest, Not a member yet? Register   Sign In
Am I an idiot or is this a bug?????? set_select
#1

[eluser]pettechservices[/eluser]
I'm going to assume its just me and I'm the idiot here... but I'm totally at a loss.

I'm using set_select and it seems upon re-population, it is not keeping the submitted value. I have CONFIRMED that I have a set_rule set for the field, so its not that.

This code works (in my view):


Code:
<select tabindex="1" name="clienttypeid" id="clienttypeid">
                <option value="0" &lt;?php echo set_select('clienttypeid', '0'); ?&gt;>Select Client Type...</option>

                <option value="1" &lt;?php echo set_select('clienttypeid', '1'); ?&gt;>Opt 1</option>
                <option value="2" &lt;?php echo set_select('clienttypeid', '2'); ?&gt;>Opt 2</option>
                
            </select>

But if I'm trying to set the options from the database, in the following code, its not working.

Code:
<select tabindex="1" name="clienttypeid" id="clienttypeid">
                <option value="0" &lt;?php echo set_select('clienttypeid', '0'); ?&gt;>Select Client Type...</option>
                &lt;?php foreach ($clienttypes->result() as $ct): ?&gt;
                <option value="&lt;?=$ct->cfg_clienttypes_id?&gt;" &lt;?php echo set_select('clienttypeid','&lt;?php echo $ct->cfg_clienttypes_id?&gt;');?&gt;>&lt;?php echo $ct->cfg_clienttypes_id?&gt;-&lt;?=$ct->cfg_clienttypes_desc?&gt;</option>
                &lt;?php endforeach; ?&gt;
            </select>


The dropdown options are populating correctly and all, but the when the form is submitted and validation FAILS, it is not keeping the proper selected option.


Any ideas??!?!?!?!!? PLEASE HELP. Thank you!
#2

[eluser]srpurdy[/eluser]
I've never used set_select, but try this below.

Instead of this
Code:
&lt;?php echo set_select('clienttypeid','&lt;?php echo $ct->cfg_clienttypes_id?&gt;');?&gt;

Try this
Code:
&lt;?php $set = set_select('clienttypeid','&lt;?php echo $ct->cfg_clienttypes_id?&gt;');?&gt;
&lt;?php if($set == $ct->cfg_clientypes_id):?&gt;selected="selected"&lt;?php endif;?&gt;
#3

[eluser]Atharva[/eluser]
It should be
Code:
&lt;?php echo set_select('clienttypeid',$ct->cfg_clienttypes_id);?&gt;
#4

[eluser]pettechservices[/eluser]
Thanks for the replies. Atharva, that was the issue. Not sure why I was thinking I had to do the echo output again, but thank you. Like I said, I was the idiot lol THANKS !!!!




Theme © iAndrew 2016 - Forum software by © MyBB