1
我希望在表單未正確提交的情況下,用戶輸入的值不會丟失。形式是建立在笨在codeigniter中不成功提交表單之後無法保留值
查看
<?php echo form_open_multipart('user/add_data'); ?>
<?php
$data = array(
'type'=>'text',
'name'=>'name',
'class'=>'form-control',
'required' => 'required',
'value' => set_value('name')
);
?>
<?php echo form_input($data); ?>
<?php
$data = array(
'type'=>'file',
'name'=>'userfile',
'class'=>'fileinput btn-info',
'id'=>'filename3',
'data-filename-placement'=>'inside',
'style' => 'margin-left: 330px',
'title'=>'If any document upload here (* XLS | DOC | PDF | DOCX | XLSX)'
);
echo form_upload($data);
?>
<?php
$data = array(
'type'=>'submit',
'class'=>'btn btn-primary pull-right',
'name'=>'submit',
'content'=>'Submit'
);
echo form_button($data);
?>
<?php echo form_close(); ?>
控制器
public function add_requirement_data() {
$config['upload_path'] = './request/';
$config['allowed_types'] = 'xls|xlsx|doc|docx|pdf';
$config['max_size'] = 9000000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile'))
{
$data = array('upload_data' => $this->upload->data());
if ($data['upload_data']['file_size'] == '0')
{
$this->session->set_flashdata('req_msg', 'Cannot Upload Empty File');
redirect('user/requirement');
}
else
{
if ($this->um->create_requirement_nofile($instanthire_main_id))
{
$this->session->set_flashdata('req_msg', 'Requirment raised successfully');
redirect('user/requirement');
}
}
}
}
誰能告訴如何保留笨形式