Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 802265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:34:26+00:00 2026-05-14T23:34:26+00:00

I’m writing a system where users can generate/run queries on demand based on the

  • 0

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 codeigniter site, but I think I’m tripping myself up.

in my view(/dashboard/dashboard_index.php), I have the following code block:

<?=form_open('dashboard/dashboard_add');?>
        <select ... name='selMetric'>
        <select ... name='selPeriod'>
        <select ... name='selSpan'>
        <select ... name='selTactic'>
        <input type="submit" name="submit_new_query" value="Add New Graph" class="minbutton" ></input>
<?=form_close();?>

Then in my controller, I have the following 2 methods:

function index() {

        $this->load->helper(array('form', 'url'));
        $this->load->library('validation');

        //population of $data

        $this->load->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->validation->set_rules($rules);

        $fields['selMetric'] = "Metric";
        $fields['selPeriod'] = "Time Period";
        $fields['selSpan'] = "Time Span";
        $fields['selTactic'] = "Tactic";
        $this->validation->set_fields($fields);

        if ($this->validation->run() == false) {
            $this->index();
        } 
        else {
            //do stuff with validation information
        }
    }

Here’s my issue. I can get the stuff to validate correctly, but for the number of errors I have, I get

Unable to access an error message corresponding to your field name.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:34:27+00:00Added an answer on May 14, 2026 at 11:34 pm

    Are you setting error messages in your validation callback functions with a message key that matches your function name (sel_check in the example below)? That is, if your callback function is named sel_check, then $this->validation->set_message has to reference sel_check as well. Your callback functions should look something like this (forgive the slightly pseudo-code. I don’t know what your validation functions actually do):

    function sel_check($var) {
        if ($var == 'something') {
            $this->validation->set_message('sel_check', 'The %s field can not be the word "something"');
            return FALSE;
        } else {
            return TRUE;
        }
    }
    

    From the documentation:

    The error message was set using the $this->validation->set_message function. Just remember that the message key (the first parameter) must match your function name.

    Also, as noted at the top of the documentation page, the validation library you are using has been deprecated and use of the form_validation library is encouraged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.