Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter select_value in form_dropdown

I have a dropdown field in my form and when I hit submit the form goes through validation and if an error happens, return all the value. This work expect for my dropdown meu, I have the set_value in the dropdown but it doesnt work :(

Here is my code

<?php echo form_dropdown('gender', $gender, set_value('gender')); ?>

What am I doing wrong or missing?

like image 953
user1269625 Avatar asked Apr 25 '26 15:04

user1269625


1 Answers

Doing this worked well:

<?php
$selected = ($this->input->post('gender')) ? $this->input->post('gender') : 'M';  
$gender = array("M" => "Male", "F" => "Female");
echo form_dropdown('gender', $gender, $selected);
?>
like image 85
user1269625 Avatar answered Apr 28 '26 04:04

user1269625



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!