我正在使用form
幫助程序類在codeigniter中創建表單。form_dropdown()沒有在codeigniter中使用「name」屬性
但是使用'form_dropdown("medium_type",$medium_type,"Select Medium")'
沒有使用name屬性,因此表單驗證在post之後不起作用。
誰能告訴我如何將名稱傳遞給元素。
function controller(){
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->data['medium_type'] = $this->field_enums('notifications', 'medium_type');
$this->data['user_type'] = $this->field_enums('notifications', 'user_type');
$this->form_validation->set_rules('medium_type', 'Medium Type', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('admin/notifications', $this->data);
}
else
{
$data = array(
'title' => $this->input->post('title'),
'medium_type' => $this->input->post('mediun_type'),
);
$this->notifications_m->insert($data);
}
$this->load->view('admin/notifications', $this->data);
}
形式代碼 ' 標題
<div class="input-field col s12 m6 l6 margin-bottom-10px">
<?php echo form_dropdown("medium_type",$medium_type);?>
<label for="medium_tyoe">Medium Type</label>
<?php echo form_error('medium_type'); ?>
</div>
<div class="input-field col s12 m12 l12 margin-bottom-10px">
<?php echo $this->ckeditor->editor("content");?>
<?php echo form_error('content'); ?>
</div>
<div class="btn waves-effect waves-light col s8 m4 l4 offset-m4 offset-l4 offset-s2 ">
<?php echo form_submit(array('id' => 'submit', 'value' => 'Submit')); ?>
<i class="material-icons right">send</i>
</div>
</div>
</div>
<?php echo form_close();?>`
這裏你下拉已'NAME =「medium_type」' – Poonam
顯示控制器代碼以及 –
加,因爲它的枚舉值的下拉如何傳遞空,數組字段(「」=>「選擇媒體類型」)在該助手? –