[eluser]Unknown[/eluser]
I am working on a form with the help of the form helper. What i wan't to do is using the form validator to validate the form and if the user is editing the form the select box needs to be set from a value that I retrieve from the database.
I have used the following code to see if it is going to work but it seem that I am doing something wrong.
Code:
<select name="primaryFocus">
<?php foreach($primaryFocusVals as $val => $text): ?>
<option val="<?=$val?>" <?=set_select('primaryFocus', $val)?>><?=$text?></option>
<?php endforeach; ?>
</select>
Code:
<select name="primaryFocus">
<?php foreach($primaryFocusVals as $val => $text): ?>
<option val="<?=$val?>" <?=set_select('primaryFocus', $val, ($primaryFocus == $val)? TRUE : FALSE)?>><?=$text?></option>
<?php endforeach; ?>
</select>
Both methods echo selected="selected" to every option. Does anyone have a solution for my problem?
With Regards,
Flex1986