title: Codeigniter : Resetting the form values
body: <p>In my view, what I want to do is clear the form fields once the user has been successfully registered. Everything works fine here i.e. the user is being registered, success message is being shown to the user except that what I want to do is the clear the values of the form fields, for which I am using this</p>
  
  <pre><code>// Clear the form validation field data, so that it doesn't show up in the forms
  $this-&gt;form_validation-&gt;_field_data = array();
  </code></pre>
  
  <p>After I added this, CI keeps giving me this error:
   Fatal error: Cannot access protected property CI_Form_validation::$_field_data in </p>
  
  <blockquote>
    <p>C:\wamp\www\CodeIgniter\application\controllers\user.php on line 92</p>
  </blockquote>
  
  <p>Here is the relevent controller code:</p>
  
  <pre><code>public function signup()
  {
      // If the user is logged in, don't allow him to view this page.
      if (($this-&gt;_isLoggedIn()) === true) {
          $this-&gt;dashboard();
      }
      else
      {
          $data['page']       = 'signup';
          $data['heading']    = 'Register yourself';
          $data['message']    = $this-&gt;_regmsg;
  
          $this-&gt;load-&gt;library('form_validation');
  
          // $this-&gt;form_validation-&gt;set_rules('is_unique', 'Sorry! This %s has already been taken. Please chose a different one.');
  
          $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]|callback_valid_username');
          $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required|matches[passconf]');
          $this-&gt;form_validation-&gt;set_rules('passconf', 'Password Confirmation', 'required');
          $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
  
          // run will return true if and only if we have applied some rule all the rules and all of them are satisfied
          if ($this-&gt;form_validation-&gt;run() == false) {
  
               $data['errors'] = isset($_POST['submit']) ? true : false;
              $data['success'] = false;
  
              $this-&gt;_load_signup_page($data);
          }
          else{
              if($this-&gt;users-&gt;register_user($_POST)){
                   $data['errors'] = false;
                  $data['success'] = true;
  
                  // Clear the form validation field data, so that it doesn't show up in the forms
                  $this-&gt;form_validation-&gt;_field_data = array();
  
                  $this-&gt;_load_signup_page($data);
              }
          }
      }
  }
  
  private _load_signup_page($data){
      $this-&gt;load-&gt;view('template/main_template_head');
      $this-&gt;load-&gt;view('template/blue_unit', $data);
      $this-&gt;load-&gt;view('signup', $data);
      $this-&gt;load-&gt;view('template/main_template_foot');
  }
  </code></pre>
  
  <p>Can anyone please tell me what's the deal with this line?</p>
  
  <pre><code>$this-&gt;form_validation-&gt;_field_data = array();
  </code></pre>
  
  <p>P.S: Here is how I am showing the values in the form:</p>
  
  <pre><code>&lt;?php echo set_value('fieldname'); ?&gt;
  </code></pre>