title: Codeigniter validation help
body: <p>I'm writing a system where users can generate/run queries on demand based on the values of 4 dropdown lists.  The lists are dynamically generated based on a number of factors, but at this point, I'm having problems validating the input using codeigniter's built in validation classes.  I think I have things out of order, and I've tried looking at the <a href="http://codeigniter.com/user_guide/libraries/validation.html" rel="nofollow noreferrer">codeigniter</a> site, but I think I'm tripping myself up.</p>
  
  <p>in my view(/dashboard/dashboard_index.php), I have the following code block:</p>
  
  <pre><code>&lt;?=form_open('dashboard/dashboard_add');?&gt;
          &lt;select ... name='selMetric'&gt;
          &lt;select ... name='selPeriod'&gt;
          &lt;select ... name='selSpan'&gt;
          &lt;select ... name='selTactic'&gt;
          &lt;input type="submit" name="submit_new_query" value="Add New Graph" class="minbutton" &gt;&lt;/input&gt;
  &lt;?=form_close();?&gt;
  </code></pre>
  
  <p>Then in my controller, I have the following 2 methods:</p>
  
  <pre><code>function index() {
  
          $this-&gt;load-&gt;helper(array('form', 'url'));
          $this-&gt;load-&gt;library('validation');
  
          //population of $data
  
          $this-&gt;load-&gt;tile('dashboard/dashboard_index', $data);
  
      }
  
  function dashboard_add()
      {
          $rules['selMetric'] = "callback_sel_check";
          $rules['selPeriod'] = "callback_sel_check";
          $rules['selSpan'] = "callback_sel_check";
          $rules['selTactic'] = "callback_sel_check";
          $this-&gt;validation-&gt;set_rules($rules);
  
          $fields['selMetric'] = "Metric";
          $fields['selPeriod'] = "Time Period";
          $fields['selSpan'] = "Time Span";
          $fields['selTactic'] = "Tactic";
          $this-&gt;validation-&gt;set_fields($fields);
  
          if ($this-&gt;validation-&gt;run() == false) {
              $this-&gt;index();
          } 
          else {
              //do stuff with validation information
          }
      }
  </code></pre>
  
  <p>Here's my issue.  I can get the stuff to validate correctly, but for the number of errors I have, I get </p>
  
  <pre><code>Unable to access an error message corresponding to your field name.
  </code></pre>
  
  <p>as the error message for everything.  I think my issue that I have the $rules and $fields stuff in the wrong place, but I've tried a few permutations and I just keep getting it wrong.  I was hoping I could get some advice on the correct place to put things.  </p>