验证失败后,CodeIgniter重新填充表单时,我遇到了问题。
HTML:
<label for="public">Anyone</label>
<input type="radio" name="target" value="public" <?php echo set_radio('target', 'public', TRUE); ?> />
<label for="direct">Specific</label>
<input type="radio" name="target" value="direct" <?php echo set_radio('target', 'direct'); ?> />当我第一次加载表单时,我得到了以下源代码:
<label for="public">Anyone</label>
<input type="radio" name="target" value="public" checked="checked" />
<label for="direct">Specific</label>
<input type="radio" name="target" value="direct" />..。因此,第三个参数正在工作(默认的"TRUE")
但是,当我在其他字段上提交带有验证错误的表单时,表单将被重新加载,没有选中单选按钮。
提交后的var_dump($_POST) (在其他字段上有有意的验证错误)显示如下:
array (size=9)
'target' => string 'direct' (length=6)
...但是没有选择单选按钮。
一定很简单..。帮助?
发布于 2014-07-11 01:13:13
答案显然是在单选按钮上添加一个假规则。
$this->form_validation->set_rules("tenderType", "", "trim");感谢@FuzzyTree指向这里的解决方案:stackoverflow.com.com/q/16473459/3574819
https://stackoverflow.com/questions/24688573
复制相似问题