我的表单中有一个下拉字段,当我点击提交时,表单会通过验证,如果发生错误,则返回所有值.这项工作期待我的下拉菜单,我在下拉菜单中有 set_value 但它不起作用:(
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 :(
这是我的代码
<?php echo form_dropdown('gender', $gender, set_value('gender')); ?>
我做错了什么或遗漏了什么?
What am I doing wrong or missing?
这样做效果很好:
<?php
$selected = ($this->input->post('gender')) ? $this->input->post('gender') : 'M';
$gender = array("M" => "Male", "F" => "Female");
echo form_dropdown('gender', $gender, $selected);
?>
这篇关于CodeIgniter select_value in form_dropdown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!