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 8544991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:41:19+00:00 2026-06-11T12:41:19+00:00

In codeigniter I have used codeigniter form validation library in many controller, ex: –

  • 0

In codeigniter I have used codeigniter form validation library in many controller,

ex: –

$this->form_validation->set_rules(‘rank’, ‘Rank’, ‘required’);

If form validation failed, Then it displays

         "The Rank field is required."

Here I want to display custom message,One method I can follow is

$this->form_validation->set_message(‘required’, ‘%s can not be blank’);

If I using this method then I need to repeat this code in every controller wherever I am using “required” form validation method

My question is there is any method to declare this custom message in configure file and automatically use this custom message whenever I using form validation rule “required”?

  • 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-06-11T12:41:19+00:00Added an answer on June 11, 2026 at 12:41 pm

    If you want to permanently over-ride the error message just hard code it into the form_validation_lang.php file.

    (Located at system/language/english)

    It you want the choice the extend the form_validation class adding your custom required function and add the appropriate error message in the lang file.

    For example;

    class MY_Form_validation {
        public function custom_required($str) {
            if ( ! is_array($str)) {
                return (trim($str) == '') ? FALSE : TRUE;
            } else {
                return ( ! empty($str));
            }
        }
    }
    

    Then in the lang file;

    $lang['custom_required'] = "%s can not be blank.";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done many CodeIgniter projects and in that i have only used $this->db->query
I am a newbie to drupal, and have used cakephp and codeigniter frameworks earlier.
I have taken over a project written in CodeIgniter, which I have never used
I have used PHP for awhile now and have used it well with CodeIgniter,
I have used Codeigniter for several years and now use it with Modular Extensions
I have codeigniter installed at the root directory, and would like to have a
Does Codeigniter 2 have a cleaner way of doing what's shown in the code,
I'm new to CodeIgniter and have come into an issue with the insertion of
I'm tinkering with CodeIgniter and have come across Active Records for the first time.
I'm new in codeigniter I have problem I use my OS X Lion, and

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.