You must set the validation rule in the field so that it can populate an invalid view. Fortunately, you can pass regular PHP functions, not just validation rules, to the set_rules() method so that you can just set the trim or something, and not the required one.
$this->form_validation->set_rules('your_field', 'Your Label', 'trim');
This will populate the field and not make it mandatory.
source share