set_value函数在codeIgniter 3中不起作用

I have to set/display the value in form fields during form_validation in codeIgniter but data is not set/displaying by using set_value function.

Here is my code,

view page -

login_form.php

<?= form_open('admin/login');?>

      <?= form_label('Username','username'); ?>
        <?= form_input(['id'=>"username", 'placeholder'=>"Username", "name"=>"username", 'value'=>set_value('username')]); ?><br>
        <?= form_error('username'); ?>
        <br>
      <?= form_label('Password', 'Password'); ?>
        <?= form_password(["id"=>"password", "placeholder"=>"Password", 
        "name"=>"pass", "value"=>set_value('pass')]); ?>
        <?= form_error('pass') ?>
        <br>
        <?php echo form_submit(['value'=>'Login']); ?>

<?= form_close(); ?>

Controller -

admin.php

public function login(){

            $this->load->library('form_validation');
            $this->form_validation->set_rules('username', 'User Name', 'required|alpha|trim');
            $this->form_validation->set_rules('pass', 'Password', 'required');

                if($this->form_validation->run()):
                    echo "Validation Success";
                    else:

                    $this->load->view('login_form']);

                endif;
        }

Please help and give suggestion regarding this.

If you not autoload Form helper add

$this->load->helper(array('form', 'url'));

and add validation_errors before your form_open

<?php echo validation_errors(); ?>

for more datails check Codeigniter Validation Form

try this

   if ($this->form_validation->run() == FALSE) { 
            echo "Validation Success";
                    else:

                    $this->load->view('login_form']);

                endif;
   }

As I mentioned you in comment.Just set value on your field like this..

<?= form_input(['id'=>"username", 'placeholder'=>"Username", "name"=>"username", 'value'=>'Sandeep']); ?><br>

Then it Will create a input field with value Sandeep.

In my case, the problem solved when I added the 'form' in the helper

$autoload['helper'] = array('form');