Validation 记住CodeIgniter form_下拉字段
这很有效Validation 记住CodeIgniter form_下拉字段,validation,forms,codeigniter,select,Validation,Forms,Codeigniter,Select,这很有效 form_dropdown('location', $location_options, $this->input->post('location')); 但当我尝试使用数组添加额外属性时,它会停止工作。。。为什么会这样 $attributes = array( 'name' => 'location', 'id' => 'location' ); form_dropdown($attributes, $location_options, $
form_dropdown('location', $location_options, $this->input->post('location'));
但当我尝试使用数组添加额外属性时,它会停止工作。。。为什么会这样
$attributes = array(
'name' => 'location',
'id' => 'location'
);
form_dropdown($attributes, $location_options, $this->input->post('location'));
下拉列表的名称包含在属性数组中,因此我看不出这与第一个示例有什么不同。无论何时将表单发回,它都会重置为开始
有人能帮我解决这个问题吗?
谢谢,只是语法不对 请看一下文档:
您的代码应该与上面的代码类似。顺便说一句:如果您使用的是表单验证库,那么可以使用set\u value而不是$this->input->post…这是错误的语法
$attributes = ' id="bar" class="foo" onChange="some_function();"';
$location_options = array(
'IN' =>'India',
'US' =>'America'
);
form_dropdown('location', $location_options, $this->input->post('location'),$attributes);
请看一下文档:
您的代码应该与上面的代码类似。顺便说一下:如果您使用的是表单验证库,那么可以使用set\u value而不是$this->input->post
$attributes = ' id="bar" class="foo" onChange="some_function();"';
$location_options = array(
'IN' =>'India',
'US' =>'America'
);
form_dropdown('location', $location_options, $this->input->post('location'),$attributes);
参数:
好的,看起来语法不对。。。没有解释如何传入属性数组并仍保留“form_input”字段中的值,但无法在不丢失post数据的情况下对“form_dropdown”字段执行相同操作。您可以将属性作为字符串添加为form_dropdown()的最后一个参数。重要信息:要使set_value()在使用表单验证库时起作用,字段(“本例中的位置”)必须是验证规则的一部分。好的,看起来语法错误。。。没有解释如何传入属性数组并仍保留“form_input”字段中的值,但无法在不丢失post数据的情况下对“form_dropdown”字段执行相同操作。您可以将属性作为字符串添加为form_dropdown()的最后一个参数。重要信息:要使set_value()在使用表单验证库时起作用,字段(“本例中的位置”)必须是验证规则的一部分。