我的表单中有一个下拉字段,当我点击提交时,表单会通过验证,如果发生错误,则返回所有值.这项工作期待我的下拉菜单,我在下拉菜单中有 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模板网!
PHP、MySQL PDOException 的死锁异常代码?Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死锁异常代码?)
PHP PDO MySQL 可滚动游标不起作用PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滚动游标不起作用)
PHP PDO ODBC 连接PHP PDO ODBC connection(PHP PDO ODBC 连接)
使用 PDO::FETCH_CLASS 和魔术方法Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔术方法)
php pdo 只从 mysql 获取一个值;等于变量的值php pdo get only one value from mysql; value that equals to variable(php pdo 只从 mysql 获取一个值;等于变量的值)
MSSQL PDO 找不到驱动程序MSSQL PDO could not find driver(MSSQL PDO 找不到驱动程序)