1

The index method in my_controller dispatches control to other methods as follows:

public function index()
{
 $this->form_validation->set_rules(some rules);
 if ($this->form_validation->run() === FALSE)
 {
  $this->load->view('main_view');
 }
 else
 {
  $action = $this->input->post('action');
  if ($action === "action_one")
  {
   $this->method_one();
  }
  elseif ($action === "action_two") 
  {
    $this->method_two();
  }
  ...............................
}

All action methods look similar. For example, method_one does the following:

public function method_one()
{
 $this->form_validation->set_rules(some rules);
 if ($this->form_validation->run() === FALSE)
 {
  $this->load->view('view_one');
 }
 else
 {
  ..........................
 }
}

And each of the numbered views sends data to the apropriate numbered method, e.g. view_one looks like

<html>
<?php echo validation_errors(); ?>
<?php echo form_open('my_controller/method_one'); ?>
 ...................................................
<input type="submit" name="submit" value="Do somdething" />
</form>
</html>

My problem is to suppress validation error messages during the first load of the view_one. During the first load of the 'main_view' they are somehow suppressed in Codeigniter by default. Please, help me. Maybe there is some hidden option extending this default behavior to successive view loads.

  • Codeigniter form validation only looks at POST requests and returns `false` with no `validation_errors` on GET. [See this answer](http://stackoverflow.com/a/10525083/3585500). – ourmandave Dec 07 '16 at 18:17
  • With this `$this->form_validation->run() === FALSE)` should be `$this->form_validation->run() == FALSE)` –  Dec 07 '16 at 20:20

0 Answers0