我试图将一个数组从我的控制器传递到<select>标签中的视图部分,以显示选项 - 不工作

I am trying to pass an array from my contoller to the view section in tag to display the options- not working it was working before when there is no form validation and model to insert the values in database. If the form validation is removed from controller then form is directly submitting with null values showing error column_name cannot be null. What is wrong in my code? Please help me out!

controller where iam passing the array to my view

public function getskill()
{
    if (!$this->session->userdata('logged_in')) {
        redirect('login');
    }

    $this->form_validation->set_rules('give_my_best', 'Give my best', 'required');
    $this->form_validation->set_rules('skills', 'Skills', 'required');
    $this->form_validation->set_rules('have_done', 'Have done', 'required');
    $this->form_validation->set_rules('work', 'I work', 'required');

    if ($this->form_validation->run() === false) {
        $this->load->view('templates/pheader');
        $this->load->view('profile/editskill');
        $this->load->view('templates/pfooter');
    } else {
        $dataArr = array(

            "give_my_best" => ["On Stage", "Back Stage", "Services"],
            "OnStage"      => ["Actor", "Modelling", "Theatre Artist", "Dancer", "Singer", "Comedian", "Stand-up", "Voice-over", "Musician", "Composer", "Stunts", "Junior Artist", "Child Artist", "Compere/Host", "Reality show artist"],
            "BackStage"    => ["Producer", "Financer", "Director", "Story Writer", "Lyricist", "Dialogue writer", "Action", "Screenplay", "Cinematography", "Art Director", "Background score", "Editing", "Choreography", "Sound design", "Special Effects", "Costume design", "Make up artist", "Content writer"],
            "Services"     => ["Prop suppplier", "Technician", "Vendor"]


        );
        $this->load->view('templates/pheader');
        $this->load->view('profile/editskill', $dataArr);
        $this->load->view('templates/pfooter');

        $this->profile_model->insert_skill();
        redirect('profile/vabout');
    }
}

Model to insert values in database

public function insert_skill() {
    $data = array(
        'give_my_best' => $this->input->post('give_my_best'),
        'occupation' => $this->input->post('skills'),
        'have_done' => $this->input->post('have_done'),
        'work' => $this->input->post('work')
    );
    $this->db->insert('profiles',$data);
}

View: This is the form where iam passing the array

<form method="post" id="editskill" action="<?php echo base_url(); ?>profile/getskill" name="editskill">
    <div class="form-group">
        <label class="col-md-3 text-right">I give my best:</label>
        <div class="col-md-9">
            <select class="chosen-select"
                    name="give_my_best"
                    data-placeholder="Give best"
                    tabindex="6"
                    id=""
                    multiple="multiple">
                <?php foreach($give_my_best as $value) { ?>
                <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                <?php } ?>
            </select>
        </div>
    </div>
    <br><br><br>
    <div class="form-group">
        <label class="col-md-3 text-right">Skills:</label>
        <div class="col-md-9">
            <select class="chosen-select" name="skills" data-placeholder="Skills" tabindex="6" id=""
                    multiple="multiple">
                <optgroup label="On Stage">
                    <?php foreach($OnStage as $value) { ?>
                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                    <?php } ?>
                </optgroup>
                <optgroup label="Back Stage">
                    <?php foreach($BackStage as $value) { ?>
                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                    <?php } ?>
                </optgroup>
                <optgroup label="Services">
                    <?php foreach($Services as $value) { ?>
                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                    <?php } ?>
                </optgroup>
            </select>
        </div>
    </div>
    <br><br>
    </div> <!-- Angular JS ends here -->
    <div class="form-group">
        <button type="submit"
                class="btn btn-primary col-md-7 col-md-offset-3 text-right"
                id="submit"
                value="submit"
                name="submit">Submit
        </button>
    </div>
</form>

In your controller, you loading the views and then also redirecting it to another

$this->load->view('templates/pheader');
$this->load->view('profile/editskill', $dataArr);
$this->load->view('templates/pfooter');

$this->profile_model->insert_skill(); //put this line before you load the views
redirect('profile/vabout'); //you can remove this line

So rearrange these line as

$this->profile_model->insert_skill();
$this->load->view('templates/pheader');
$this->load->view('profile/editskill', $dataArr);
$this->load->view('templates/pfooter');

And you don't need to use two different functions inside the controller to submit a form, You can do it with a single function and you just need to check if form submitted then #insert code else show the normal view