title: Codeigniter, Fat models and skinny controller
body: <p>I’m busy with my first codeigniter “practice” project. I’ve used flexi_auth as a validation library and really liked the way that they implement the form validation in the model and not in the controller, thus sticking to MVC(Fat models) principal.</p>
  
  <p>I’m trying to build another one of my forms with the same logic but for the life of me I can’t seem to get the error message set by validation errors from the model via the controller to the view. Please note I’m using a layout helper, thus the abnormal call to view.</p>
  
  <p>Any help will be appreciated. Here is my code:</p>
  
  <p>Controller:</p>
  
  <pre><code>//Start Information Desk Query()
  public function information()
  {
    if ($this-&gt;input-&gt;post(‘informationForm_submit’))
    {
    $this-&gt;load-&gt;model(‘contact_model’);
    $this-&gt;contact_model-&gt;information_post();
    // information_post validation failed
    }
  
    $this-&gt;data[‘title’] = ‘Information Desk’;
    $this-&gt;layout-&gt;show(‘contact/information_view’, $this-&gt;data);
  
  }
  //End Information Desk Query()
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>//Start Information Request()
  public function information_post()
  {
  
    $validation_rules = array(
    array(‘field’ =&gt; ‘informationEmail’, ‘label’ =&gt; ‘Email’, ‘rules’ =&gt; ‘required|valid_email’),
    array(‘field’ =&gt; ‘informationQuery’, ‘label’ =&gt; ‘Message’, ‘rules’ =&gt; ‘required|max_length[500]’)
    );
  
    $this-&gt;form_validation-&gt;set_rules($validation_rules);
  
    if ($this-&gt;form_validation-&gt;run())
    {
    return TRUE;
    }
    else
    {
    $this-&gt;data[‘message’] = validation_errors(’&lt;li class=“error_msg”&gt;’, ‘&lt;/li&gt;’);
    return FALSE;
    }
  
  }
  //End Information Request()
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;?php
  
        if (! empty($message))
        {
          echo ‘&lt;div class = “error_message”&gt;
          &lt;div class =“error_header”&gt;Please correct the following&lt;/div&gt;
          &lt;div class = “error_image my-icons-Actions-window-close-icon”&gt;&lt;/div&gt;
          &lt;ul class = “error_text”&gt;’.$message.’&lt;/ul&gt;&lt;/div&gt;’;
        }
    ?&gt;
  </code></pre>
  
  <p><em>*</em>*Please note that the form validation is functional in this code. If I put the following:
  echo $this->data[‘message’];</p>
  
  <p>....in the model then the errors are displayed but obviously not as a part of my view file but before it. 
  PS. please take it easy if this is a stupid question but I am a newbie to codeigniter and actually to MVC.</p>