Welcome Guest, Not a member yet? Register   Sign In
Silly Dropdown issue
#1

[eluser]kevinprince[/eluser]
I am using the new Form Validation class on a project and I am having issues with the form.

When I load the form for the first time:

Code:
<?php echo set_select('acid', $item['acid']); ?>


Seems to be setting every item to selected even I set the default to FALSE.

Full Select Box Code
Code:
<select name="acid" id="acid" class="medium">
  <option value="0" &lt;?php echo set_select('acid', '0'); ?&gt;>Select an Option</option>
  &lt;?php foreach ($accounts as $item): ?&gt;
  <option value="&lt;?= $item['acid']; ?&gt;" &lt;?php echo set_select('acid', $item['acid']); ?&gt;>
  &lt;?= $item['account_name'] ?&gt; | &lt;?= $item['address'] ?&gt;
  </option>
  &lt;?php endforeach; ?&gt;
</select>

When reloading on the repopulate, it actually defaults to nothing selected.

Quite confused, help appreciated.
#2

[eluser]crumpet[/eluser]
I'm guessing you want just option 0 to be selected - then make it set_select('acid', 0, TRUE) to default to that if there is no other value.
#3

[eluser]kevinprince[/eluser]
Tried that, didnt work, also tried hard coding the selected.

For now ive written my own function which does if $x = $y then echo selected.

I assume $var1 is the $_POST var which is called $acid but it doesnt seem to be hitting it right.

Might be me doing something odd in the controller, but workaround is fine for now.
#4

[eluser]mattthehoople[/eluser]
Are you just missing $this->validation-> ?

&lt;?=$this->validation->set_select('acid', $item['acid']);?&gt;
#5

[eluser]mattthehoople[/eluser]
Sorry, just noticed "new" Form Validation Class... ignore me...




Theme © iAndrew 2016 - Forum software by © MyBB