View
<div class="box-body">
<div class="form-group">
<label for="FNAME" class="col-sm-2 control-label col-sm-offset-2"> <span>*</span>First Name:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="FNAME" name="FNAME">
</div>
</div>
<div class="form-group has-error col-sm-offset-7">
<label class="control-label" for="error"><?php echo form_error("FNAME"); ?></label>
</div>
</div>
Controller
public function create_id() {
$this->form_validation->set_rules('FNAME', 'First Name' ,'trim|required|max_length[30]');
$this->form_validation->set_rules('MNAME', 'Middle Name' ,'trim|max_length[30]');
$this->form_validation->set_rules('SURNAME', 'Last Name' ,'trim|required|max_length[30]');
if($this->form_validation->run($this) == FALSE) {
$this->add_view();
} else {
if($query = $this->Employees_Model->insert()) {
$this->autoid();
redirect('Employees/index');
} else {
$this->add_view();
}
}
}
What I want is if($this->form_validation->run($this) == FALSE){
as you see it will redirect back to view. $this->add_view();
all I want is when it redirects back, the data that I input will remain. so that I will not input it again when the validation fails.