我想让邮件是必填字段,但不知道它不起作用,我错过了什么?
<div class="col-md-5 ">
<div class="control-group form-group">
<label class="control-label">
Escalation Email Ids
</label>
<div class="controls">
<?php $options=a rray(); if(count($useridsoptions)){ foreach($useridsoptions as $key=>$val){ $options[$key]=$val; } } echo form_dropdown('esc_users[]', $options, explode(",",$row->esc_users),'id="esc_users" class="form-control function col-md-12 select2", reqired="required" multiple'); ?>
</div>
</div>
</div>
答案 0 :(得分:1)
Codeigniter下拉列表验证示例
<?php echo form_label("Country:
","country");
$data = array(
"selectcountry" => "Select Country",
"CA" => "Canada",
"US" => "United States",
"ZW" => "Zimbabwe"
);
echo form_dropdown('country', $data, 'selectcountry');?>
表单验证规则
<?php $this->form_validation->set_rules('country', 'Country', 'required|callback_country_check');?>
回调方法
public function country_check()
{
if ($this->input->post('country') === 'selectcountry') {
$this->form_validation->set_message('country_check', 'Please choose your country.');
return FALSE;
}
else {
return TRUE;
}
}
答案 1 :(得分:1)
注意到代码中的几个问题。
required
&amp; array
拼写错误,而form_dropdown()
函数
试试这个
<div class="col-md-5 ">
<div class="control-group form-group">
<label class="control-label">
Escalation Email Ids
</label>
<div class="controls">
<?php $options=array(); if(count($useridsoptions)){ foreach($useridsoptions as $key=>$val){ $options[$key]=$val; } } echo form_dropdown('esc_users[]', $options, explode(",",$row->esc_users),'id="esc_users" class="form-control function col-md-12 select2" required="required" multiple'); ?>
</div>
</div>
</div>